I have written (cobbled together is probably more accurate) many macros over the last 20 years. I'm by no means proficient, and the simple things still get me confused. One of those is the syntax for defining ranges.
From my current point of view, there seems to be no consistency to it all:
When to use Range
When to use Cells
When to use ,
When to use :
When to use &
When to use column then row
When to use row then column
Where the " quotation marks go
An example: Something like Range("A1:M" & LastRow) works, as does Range("A1", "M" & LastRow), but Range("A1":LastCol&LastRow) does not; niether does Range("A1", LastCol & LastRow)
My immediate problem that lead to writing this post is that I need the correct syntax for addressing A1:LastCol and LastRow
I'm familiar with Range("A1", "D" & LastRow), but cannot work out how to get LastCol AND LastRow in there.
I have searched in vain to find a simple explanation but have come up empty. Can someone point me to something I can bookmark, so I don't have to ask such simple questions on this forum?
From my current point of view, there seems to be no consistency to it all:
When to use Range
When to use Cells
When to use ,
When to use :
When to use &
When to use column then row
When to use row then column
Where the " quotation marks go
An example: Something like Range("A1:M" & LastRow) works, as does Range("A1", "M" & LastRow), but Range("A1":LastCol&LastRow) does not; niether does Range("A1", LastCol & LastRow)
My immediate problem that lead to writing this post is that I need the correct syntax for addressing A1:LastCol and LastRow
I'm familiar with Range("A1", "D" & LastRow), but cannot work out how to get LastCol AND LastRow in there.
I have searched in vain to find a simple explanation but have come up empty. Can someone point me to something I can bookmark, so I don't have to ask such simple questions on this forum?