3

What is the difference between

Range("A1","A40").Select 
Range("A1:A40").Select

Though both of them produce the same result. I would like to know the difference between them

Community
  • 1
  • 1
Rohit Saluja
  • 1,517
  • 2
  • 17
  • 25
  • 1
    I guess there's no difference it's just two different ways of doing the same thing. Syntax is `Range(Cell1.Address,Cell2.Address)` where `Cell2.Address` is optional. The correct question would be "what's the difference between Cell and Range ?". – Stupid_Intern Apr 17 '16 at 14:51
  • Eg. You can also do `Range("A1:A40","A80").Select` which will select A1 to A80 Cells. – Stupid_Intern Apr 17 '16 at 14:57
  • AFAIK a cell is a range, – Rohit Saluja Apr 17 '16 at 15:19

1 Answers1

1

There's no difference. It is only a form of easiness in vBA language that let you assign or call the same objects' properties or methods in many different ways.

You can also select the same range with the following syntax

Range(Cells(1, 1), Cells(1, 40))

While I might understand your confusion if you have practiced other "strict" programming languages, this should not disturb you. Just view this as more flexibility provided by vba language and syntax

Thomas G
  • 9,886
  • 7
  • 28
  • 41