iterate columns to select certain cells
hei Dale
try this
Sub DynColNr()
Dim Lc As Long
Dim j As Long
Dim kol As String
' count columns (and change "Ark1" to your sheet name)
Lc = Sheets("Ark1").Range("IV1").End(xlToLeft).Column
For j = 1 To Lc
kol = ColumnLtr(j)
Range(kol & "2:" & kol &
ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell) .Row).Select
' do things here.
Next j
'MsgBox kol
End Sub
Public Function ColumnLtr(ByVal Column_Number As Long) As String
'Converts a number to a Column Letter
'Leith Ross
Dim Ltr As String
Dim N1 As Long
Dim N2 As Long
'Column must greater than 0
Column_Number = Column_Number - 1
If Column_Number < 0 Then
ColumnLtr = ""
Exit Function
End If
'Maximum Column value is 256
If Column_Number 256 Then Column_Number = Column_Number Mod 256
'Convert to Column_Number Base 26
N1 = Column_Number \ 26
N2 = Column_Number Mod 26
'Convert number to Alpha characters
If N1 = 0 Then
Ltr = ""
Else
Ltr = Chr$(64 + N1)
End If
Ltr = Ltr & Chr$(65 + N2)
ColumnLtr = Ltr
End Function
regards Yngve
|