Assign Cell Values without a Loop

B

BHatMJ

I have a large number of cells that I "reset" to a default value. Is there
anyway to assign all of the cells to the default value at one time without
using a loop?
 
B

Bob Phillips

Range("B2:10").value = "abc"

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
R

Rick Rothstein \(MVP - VB\)

Range("B2:10").value = "abc"

Typo alert... Bob accidentally left out the column designation for the
ending cell of the range...

Range("B2:E10").Value = "abc"

Rick
 
B

BHatMJ

Thank you both. If I took that a step further, would it be valid to have the
following command also?

Sheets(1).Range("B2:B10").value = Sheets(2).Range("B2:B10").value
 
R

Rick Rothstein \(MVP - VB\)

Seems like that would have been easy enough to test instead of waiting more
than half an hour for me to tell you "Yes, that appears to work". However, I
think my preference would be to do it this way though...

Sheets(1).Range("B2:B10").Copy Sheets(2).Range("B2")

or, if you prefer, this the more self-documenting form...

Sheets(1).Range("B2:B10").Copy Destination:=Sheets(2).Range("B2")

Rick
 
Top