Two similar VBA Excel code


Here are two VBA property codes on the RANDE that mean the same thing:

Range("A1:A10").Value = 99

Range(Cells(1, 1), Cells(10, 10)).Value = 99

In which case the second one really had to be used?

In other words, in which case the property Cells, referring to the RANGE is really used?

1 Reply

I am assuming the second line was to read as below if they were to match.


Range(Cells(1, 1), Cells(10, 1)).Value = 99

Using Range with Cells would typically be used when one of the properties of Cells is to be a variable, easy enough to do   "A" & i   however if we wanted a variable for the row number but it becomes messy if we want the Column letter to be a variable, much easier to work with integers as variables using Cells with Range vs. using letters with Range without Cells. 


Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies