One of my favorite new "Toys" in VBA is the command Evaluate. For those of you who do not know what this does, it is one of the more powerful tools available to you, so I highly suggest playing with it.
Evaluate basically takes a string and runs any functions based on that string (or at least that is my understanding of it). So, if you did:
i = evaluate("3 + 4")
msgbox(i)
You would get a message box showing 7.
Evaluate also works with functions you create... so if you did the following:
[vba]Public Function getColLtr(i As Integer)
getColLtr = Split(Sheet1.Cells(1, i).Address, "$")(1)
End Function
Sub test2()
Dim s As String
s = "getColLtr(5)"
MsgBox (Evaluate(s))
MsgBox (getColLtr(5))
End Sub
[/vba]
You will get two message boxes of "E". That is to be expected. What I found interesting is that when I run the code in step mode, it never steps through the function when Evaluating, but it does step through when iterating the second message box.
Bizarre. I tested to see if evaluate was more efficient (ran faster) than the same function without evaluate, and no big surprise, the act of evaluating makes the function less efficient. I just think it is interesting in the step through that it does not iterate through any functions.
No questions here, just an odd observation.
Thanks.