It depends how you want the macro to work.
You could write a UDF (User-Defined Function) which would let you use a worksheet formula to call a custom block of code.
Alternatively you could write a macro to churn through a whole range of data (everything in a column, say) and return the value. Or you could write a macro which calls a UDF. The options are virtually endless.
Try the following code...
This starts with row 1 in column 1 on the currently active sheet and loops through column A until it finds a blank, for each entry it puts the return value that you want into column 2. Is that the sort of thing you were looking for?
Generally using worksheet functions is faster than running a macro, but if the data is going to be static once it's in Excel then there's no real issue with using VBA to do the job.
Bookmarks