Hi all,

I am trying to put together a macro that loops across cells along columns, once it gets to an empty/blank cell it loops down rows. If all the cells in that column and range of rows are empty/blank - the macro hides the column, then continues on until the range of columns has reached the end.

The range of columns will always be from 2 (B) to 23 (w)
The range of rows will always start from 11 and be a variable length (never more than 200).


So far i have the below code:

This code runs along columns fine and checks to see if the cell is blank on row 11. However i've not managed to code the second part of the loop where it then goes down that column to check if the subsequent cells in the rows beneath are blank.

The macro currently runs along the columns and then goes down to the next row (which i do not need).

Dim i As Long
Dim j As Long

Dim current_cell As Object


Dim beg_col As Long
Dim end_col As Long
Dim beg_row As Long
Dim end_row As Long

beg_col = 2
end_col = 23
beg_row = 11
end_row = Range("b50000").End(xlUp).Row

For i = beg_row To end_row Step 1
    
    For j = beg_col To end_col Step 1
    
    Set current_cell = ThisWorkbook.ActiveSheet.Cells(i, j)
    
    If j And current_cell.Value = " " Then
    MsgBox "empty"
    
    End If
    
    Next j

I realise this may be rather confusing, however any help would be appreciated.