Hide Column If Usedrange of Column ISBLANK
Hi Ron
Try this:
Sub HideEmptyRows()
StartRow = 12
For Each col In Columns("E:AI")
ColAdr = col.Address
TargetCol = IIf(Mid(col.Address, 4, 1) = "$", _
Mid(col.Address, 2, 1), Mid(col.Address, 2, 2))
LastRow = Range(TargetCol & Rows.Count).End(xlUp).Row
RowCount = Range(TargetCol & 12, TargetCol & LastRow).Rows.Count
EmptyRows = WorksheetFunction.CountBlank _
(Range(TargetCol & 12, TargetCol & LastRow))
If RowCount = EmptyRows Then Columns(TargetCol).Hidden = True
Next
End Sub
Regards,
Per
skrev i meddelelsen
...
Hi guys,
I've searched and tried to reuse some of the code to fit my needs but,
so far I've not been successful. So, my last resort is to ask for
your assistance. I'm trying to Loop through Columns E:AI's used
range, beginning with row 12. Number of rows could be from 1 to 5000
rows. I need to hide columns that have blanks in all rows (12 to ?)
for that column. Appreciate your assistance and thank you in
advance. Ron
|