ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Assign Cell Values without a Loop (https://www.excelbanter.com/excel-discussion-misc-queries/189183-assign-cell-values-without-loop.html)

BHatMJ

Assign Cell Values without a Loop
 
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?

Bob Phillips

Assign Cell Values without a Loop
 
Range("B2:10").value = "abc"

--
---
HTH

Bob


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



"BHatMJ" wrote in message
...
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?




Rick Rothstein \(MVP - VB\)[_564_]

Assign Cell Values without a Loop
 
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


BHatMJ

Assign Cell Values without a Loop
 
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



"Rick Rothstein (MVP - VB)" wrote:

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



Rick Rothstein \(MVP - VB\)[_567_]

Assign Cell Values without a Loop
 
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


"BHatMJ" wrote in message
...
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



"Rick Rothstein (MVP - VB)" wrote:

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





All times are GMT +1. The time now is 01:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com