ShCO01 is the worksheets CodeName
These are the variables needed
I have a header in row 4 that is growing in length and every once-in-awhile I add Row to my data sets.
I want the VBA code to search my header and when it finds Row it starts one row below it and places the row number down the column until the LDR1 (last data row).
My last attempt was……and of course it’s not working.
These are the variables needed
VBA Code:
With ShCO01
Dim LVC1 As String: LVC1 = .Cells(4, Columns.Count).End(xlToLeft).Value (needed for cell contents)
‘Last Value in last header
Dim LDC1 As Long: LDC1 = .Cells(4, Columns.Count).End(xlToLeft).Column
‘Last Data Column
Dim LDR1 As Long: LDR1 = .Range(.Cells(5, "C"), .Cells(150, LDC1)).Find("*", , , , xlByRows, xlPrevious).Row
‘Last Data Row in varying range
MsgBox "Last header in 4th row is column # " & LDC1 & " (" & Split(Cells(, LDC1).Address, "$")(1) & ") with a data collection for """ & LVC1 & """ and Last Data Row is " & LDR1
End With
I want the VBA code to search my header and when it finds Row it starts one row below it and places the row number down the column until the LDR1 (last data row).
My last attempt was……and of course it’s not working.
VBA Code:
With ShCO01
Dim cll as Range
For Each cll In .Range(.Cells(4, "C"), .Cells(4, LDC1)).Cell
Select Case cll.Value = "Row"
Case True
cll.Offset(1, 0).Resize(LDR1, 0).Value = "=Row()"
Case False
cll.value = “”
End Select
Next
End With