[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Letter alternative to 1 - 26

keri

12/15/2006 5:01:00 PM

I have used the code;

Dim i as integer
For i = 1 to 26

a lot to refer to sheets and rows numbered consequtively. However I am
writing code with the lines below;

ActiveCell.Offset(1, 1) = Sheets("drivers").Range("a1")
ActiveCell.Offset(1, 1) = Sheets("drivers").Range("b1")
ActiveCell.Offset(1, 1) = Sheets("drivers").Range("c1")
ActiveCell.Offset(1, 1) = Sheets("drivers").Range("d1")

And i wondered if there was a way to do a similar thing in this code
with the column letters. I guess it will be a way of referring to the
column instead of having the above code for 35 lines referring to each
column individually. Can anyone suggest the way to but a Next in this
code so I can shorten my macro considerably?

1 Answer

Roger Govier

12/15/2006 5:12:00 PM

0

Hi

Dim i As Integer
For i = 1 To 26
ActiveCell.Offset(0, i) = Sheets("drivers").Cells(1, i)
Next


--
Regards

Roger Govier


"keri" <keri.dowson@diageo.com> wrote in message
news:1166195989.228099.112070@j72g2000cwa.googlegroups.com...
>I have used the code;
>
> Dim i as integer
> For i = 1 to 26
>
> a lot to refer to sheets and rows numbered consequtively. However I am
> writing code with the lines below;
>
> ActiveCell.Offset(1, 1) = Sheets("drivers").Range("a1")
> ActiveCell.Offset(1, 1) = Sheets("drivers").Range("b1")
> ActiveCell.Offset(1, 1) = Sheets("drivers").Range("c1")
> ActiveCell.Offset(1, 1) = Sheets("drivers").Range("d1")
>
> And i wondered if there was a way to do a similar thing in this code
> with the column letters. I guess it will be a way of referring to the
> column instead of having the above code for 35 lines referring to each
> column individually. Can anyone suggest the way to but a Next in this
> code so I can shorten my macro considerably?
>