jocker_boy
Board Regular
- Joined
- Feb 5, 2015
- Messages
- 83
Hello,
I'm trying to create a column group based on my cells that are empty in row 4.
I have this code working perfect:
But my column name is variable, so i would like to replace with this:
But it doesn't work.
Thanks for all the help.
Gonçalo
I'm trying to create a column group based on my cells that are empty in row 4.
I have this code working perfect:
VBA Code:
Sub MakeGroups()
Dim rA As Range
For Each rA In Range("ED4", Range("ED4").End(xlToRight)).SpecialCells(xlCellTypeBlanks)
rA.EntireColumn.Group
Next rA
End Sub
But my column name is variable, so i would like to replace with this:
VBA Code:
Sub MakeGroups()
Dim rA As Range
Dim lc As Long
'Find last column in row 1 with data
lc = Cells(1, Columns.Count).End(xlToLeft).Column
For Each rA In Range(Cells(4, lc + 1), Range(Cells(4, lc + 1)).End(xlToRight)).SpecialCells(xlCellTypeBlanks)
rA.EntireColumn.Group
Next rA
End Sub
But it doesn't work.
Thanks for all the help.
Gonçalo