Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA: Range Syntax Confusion

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

like image 243
Rohit Saluja Avatar asked Jan 27 '26 16:01

Rohit Saluja


1 Answers

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

like image 169
Thomas G Avatar answered Jan 30 '26 18:01

Thomas G



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!