ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can column character be added? (https://www.excelbanter.com/excel-programming/384924-can-column-character-added.html)

jimmy[_5_]

Can column character be added?
 
I use to assign value to the cells A1 B1 C1....BA1, how to do this by using
a for loop? I have tried "A" + 1 be it is not equal to B since the type
error...



Vergel Adriano

Can column character be added?
 
something like this puts a number for A1 through J1 in Sheet1

Dim iColumn As Integer
For iColumn = 1 To 10
Sheet1.Cells(1, iColumn).Value = iColumn
Next iColumn


"jimmy" wrote:

I use to assign value to the cells A1 B1 C1....BA1, how to do this by using
a for loop? I have tried "A" + 1 be it is not equal to B since the type
error...




Tom Ogilvy

Can column character be added?
 
for each cell in Range("A1:BA1")
cell.Value = Int(rnd()*100+1)
Next

is one way

for i = 1 to 53
cells(1,i).Value = Int(rnd()*100+1)
next

is another.

For i = 0 to 52
Range("A1").offset(0,i).value = int(rnd()*100+1)
next

is yet another.

--
Regards,
Tom Ogilvy


"jimmy" wrote:

I use to assign value to the cells A1 B1 C1....BA1, how to do this by using
a for loop? I have tried "A" + 1 be it is not equal to B since the type
error...





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

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