Hi
I want to search a range of data, if the entire column within the range is empty, I want to hide the column. So far I am looping through the range with to loops. This is probably not the most efficient way. Can sombody please adcise me on this?
My code:
Sub Test2()
Dim sStartRange
Dim lCol, lRow
sStartRange = "E22"
Range(sStartRange).Select
For lCol = 1 To 5
For lRow = 1 To 5
If ActiveCell.Value = "" Then
Selection.Offset(1, 0).Select
Else
Selection.Offset(1, 0).Select
iCount = iCount + 1
End If
Next
If iCount = 0 Then
Selection.EntireColumn.Hidden = True
End If
Selection.Offset(-lRow, 1).Select
iCount = 0
Next
End Sub
Regards,
SmithcZA
I want to search a range of data, if the entire column within the range is empty, I want to hide the column. So far I am looping through the range with to loops. This is probably not the most efficient way. Can sombody please adcise me on this?
My code:
Sub Test2()
Dim sStartRange
Dim lCol, lRow
sStartRange = "E22"
Range(sStartRange).Select
For lCol = 1 To 5
For lRow = 1 To 5
If ActiveCell.Value = "" Then
Selection.Offset(1, 0).Select
Else
Selection.Offset(1, 0).Select
iCount = iCount + 1
End If
Next
If iCount = 0 Then
Selection.EntireColumn.Hidden = True
End If
Selection.Offset(-lRow, 1).Select
iCount = 0
Next
End Sub
Regards,
SmithcZA