Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help: loop through colums

Status
Not open for further replies.

Timme1

Technical User
Oct 6, 2002
15
0
0
BE
Hello,

I created a While loop where I go through colums.

in the beginning of the sub: k = 1

in the loop is a command:
columns(k).select

and at the end of the loop:

k = k+1

Now there is a big problem: when the column is at the "Z"-column, he goes back to the A-column with with this method, While I want to select the AA-column after the Z-column!

Does someone has an idea how I can solve this problem?

Thank you in advance,

Timme
 
I'm not sure what your trying to do? Can you post the code for the Loop???
 
so k=1
how are you setting the lower and upper limits of the loop ??

For k = 1 to ???

For each c in worksheet.columns ??

Do while ?? Rgds
~Geoff~
 
Timme1:

I believe there to be some other problem with your code. If you run the following example written as you describe it selects each of the columns from A to IV.
Code:
Sub LoopColumns()
  Dim iCol As Integer
  iCol = 1
  Do While iCol <= 256
    Columns(iCol).Select
    iCol = iCol + 1
  Loop
End Sub
Check to verify you are not resetting your Column variable when it exceeds the 26th column.

Regards, LoNeRaVeR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top