Home » excel » excel – Is there a way to fully qualify the use of a VBA function?

excel – Is there a way to fully qualify the use of a VBA function?

Posted by: admin May 14, 2020 Leave a comment

Questions:

So I just learned that if you type VBA. this will activate an auto list that includes VBA functions. Does this mean that VBA is an object? If I want to “fully qualify” using a VBA function, what would those qualifiers be?

For example, would these all be valid statements:

x = Sqr(25)
x = VBA.Sqr(25)
x = Application.VBA.Sqr(25)

Thanks for the clarification.

How to&Answers:

If you don’t qualify, the default is that VBA assumes it is a VBA function. If you want to use a worksheet function in VBA, then use something like:

x = Application.WorksheetFunction.VLookup(Range("A1").Value, Range("B1:C100"), 1, False)

It is REALLY important to qualify if you use a function likeTRIM() because the VBA version and the worksheet version have different results.