I'm trying to write a VBA function to be called from a cell. In this function I need to use the CurrentRegion property but it returns an unexpected result.
The function:
Function GetVarRange() As String
Dim rngRangeToLeft As Range, wks As Worksheet
Set wks = Application.Caller.Worksheet
Set rngRangeToLeft = wks.Range("A1").CurrentRegion
GetVarRange = rngRangeToLeft.Address
End Function
The result I get in the cell is $A$1.
There are values in A1, and all around it, the CurrentRegion is actually A1:AD618 and this is the result I get when I access the property within the code editor (not in this function) and when I press ctrl+A when A1 is selected.
Any ideas anyone?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…