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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through the alphabet

Status
Not open for further replies.

aharris2693

Programmer
Jul 15, 2003
45
US
Is there a VBA function for moving to the next letter in the alphabet? My loop is based on an integer, and I have considered using a select case to read each letter and change it to the next one. I only have 43 columns, so I could do this, but if there is a simpler way it would be great. Thanks
 
Thanks Skip
As soon as I posted this I remembered how to do it. A small brain lapse I guess. Thanks again.
 
It sounds like you don't really need to get the next letter of the alphabet. It sounds like what you want is to get the next column in a worksheet.

I would recommend that you take this opportunity to begin to understand how to work with ranges as objects. It will stand you in good stead with future VBA coding issues. Study this sample code and see what you can learn:
[blue]
Code:
Option Explicit

Sub Demo()
Dim col As Range
Dim i As Integer
  Set col = Range("A1").EntireColumn
  For i = 1 To 4
    DoSomethingWithAColumn col
    Set col = col.Offset(0, 1)
  Next i
  Set col = Nothing
End Sub

Sub DoSomethingWithAColumn(AColumn As Range)
   MsgBox AColumn.Address
End Sub
[/color]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top