April 17th, 2002, 10:56 am
hi applet.i come from a c++ programming background. Contrary to pinball wizard would recommend Excel 2000 VBA Programmers Reference by Wrox (Green et al.) as a book, but not to start off with. It has the complete object model for excel letting you get down to the nitty gritty. Pinball Wizard is correct though in saying that this is all available in Excel (in the object browser) and that it is definetly a reference book, rather than a teaching book. (i.e. get it when you want to have some fun, rather than to learn VBA!) It is also more about writing automated tasks in excel than doing financial calculations (e.g. it will help you to write something that automatically plots a graph, for instance). As for learning VBA: 1) the basic syntax is fairly easy ...Function FuncA( x, y, z)' comments are like this!! (i.e. with ' before the line). Dim a, b, c FuncA = a*x + b*y +c*zEnd Functionyou assign the result to the function name to return it. the Dim keyword allocated memory for the variable, which in this case are all VARIANT. You can optimise it a bitby either "as double" or "#" --> so C++ "int x;" is declared "Dim x%" or "Dim x as integer" and "double y;" becomes "Dim y#" or "Dim y as double"That is the guts of it. Press F2 to see the object browser. You can search for functions. Some, e.g. NormDist, have to be accessed thus:WorkSheetFunction.NormDistAnd you can call your new function FuncA from the worksheet. I think if you have a go then your C++ background will come into play and you will pick things up very quickly.2) Advanced modelling in finance using Excel and VBA by Mary Jackson & Mike Staunton introduces financial applications of Excel VBA and introduces you to the VBA you need. 3) Read any introduction to VBA. Most of these books will be looking at all the stuff in the Green book (above) which for financial maths you don't really need. I used the help files and also Writing Excel Macros by Steven Roman (O'Reilly). This book aint financial though! (If you want a VBA add-in with funky dialog which automatically prduces a graph, then these are the skills that you need. )