Visual Basic dot operator syntax without object name

In my previous life, I wrote several Visual Basic, and today I need to resurrect these skills in order to write Excel Macro. While Internet trawling is looking for VBA examples to help us with this Excel macro, I came across this unusual syntax:

Set rFound = .Columns(1).Find(What:="Cat", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False)

Pay attention to .Columns and .Cells - point operators do not have object names on the left.

I remember this syntax for a long time, but I do not remember the details. It's hard for me to find anything useful on Google or on MSDN.

Questions:

  • When is this legal?
  • What variable does the point operator represent?
  • Where can I get more information?

Thanks.

+5
source share
1 answer

, . :

With testObject
    .Height = 100
    .Text = "Hello, World"
    .Rows = 20
    .Cols = 20
End With

VB With . MSDN

+13

All Articles