I need to be able to hide rows in a table if the first column is blank. I need the macro to work on tables in different sheets so I search for the table name first using listobjects, I have no problem getting the table name. I have seen how to accomplish this with a general range of cells, but not within a Table. Any help is appreciated.
I have a similar macro to unhide rows in the table and it works fine because it simiply loops through all rows in the ListObject variable 'MyTable' and does not have the IF statement.
HideBlankTableRows()
Application.ScreenUpdating = False
Dim ws As Worksheet
Dim myTable As ListObject
Dim row As Range
Set ws = ActiveSheet
Set myTable = ws.ListObjects(1)
For Each row In myTable.DataBodyRange
If row.Columns(1, 1).Value = "" Then ' Error is caused by this row
row.Hidden = True
End If
Next
End Sub