ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   input of single value into multiple cells simultaneously (https://www.excelbanter.com/excel-programming/355026-input-single-value-into-multiple-cells-simultaneously.html)

Joe[_42_]

input of single value into multiple cells simultaneously
 
Hi,

I'm trying to enter a bunch of asterisks into a range of cells (columns
A through I) in a row "i" in a worksheet that has been defined as SHD.
The macro has already "read" the value of i correctly. However, when I
use the following code, it gives me an error code. Could you tell me
what is wrong with this ?

SHD.Range(Cells(i, 1), Cells(i, 9)) = "********"

Appreciate any help.

Thanks,

Joe.


Tom Ogilvy

input of single value into multiple cells simultaneously
 
SHD.Range(SHD.Cells(i, 1), SHD.Cells(i, 9)) = "********"

or

With SHD
.Range(.Cells(i,1),.Cells(i,9)) = "********"
End With

or
SHD.Cells(i,1).Resize(1,9) = "********"

--

Regards,
Tom Ogilvy


"Joe" wrote in message
oups.com...
Hi,

I'm trying to enter a bunch of asterisks into a range of cells (columns
A through I) in a row "i" in a worksheet that has been defined as SHD.
The macro has already "read" the value of i correctly. However, when I
use the following code, it gives me an error code. Could you tell me
what is wrong with this ?

SHD.Range(Cells(i, 1), Cells(i, 9)) = "********"

Appreciate any help.

Thanks,

Joe.




Joe[_42_]

input of single value into multiple cells simultaneously
 
Thanks a lot, Tom. Incidentally, I saw this other option - formulaR1C1,
and used it. I have one more question though - why is it that I have to
define SHD specifically into each of the cells address in:

SHD.Range(SHD.Cells(i, 1), SHD.Cells(i, 9)) = "********"

Thanks,

Joe.


Tom Ogilvy

input of single value into multiple cells simultaneously
 
If you don't they refer to the Activesheet. Or if you are using them in a
sheet module, the unqualified range reference it interpreted to refer to the
sheet containing the code.

Since you are not assigning a formula, then Value would be more appropriate.
However, the end result will be the same. There is also Formula.

Just for illustration

With Range("A1")
.Formula =
.FormulaR1C1 =
.Value =
.FormulaLocal =
.FormulaR1C1Local =

End With

Don't just grab something out of the hat - look at the help and see which is
appropriate. Sometimes it makes no difference, other times it does.

--
Regards,
Tom Ogilvy


"Joe" wrote in message
oups.com...
Thanks a lot, Tom. Incidentally, I saw this other option - formulaR1C1,
and used it. I have one more question though - why is it that I have to
define SHD specifically into each of the cells address in:

SHD.Range(SHD.Cells(i, 1), SHD.Cells(i, 9)) = "********"

Thanks,

Joe.





All times are GMT +1. The time now is 07:15 PM.

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