How to delete columns with headings but rows are empty

D

Deb

Hi,
I have data where columns have headings but rows are blank. I have
approx 500 rows of data.

ID Student Course 1 Course 2
2 Tom 0
3 Suzie

Thanks for your assistance
 
M

Mike H

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
M

Mike H

Deb,

If I understand correctly we loop through columns and if there are no data
in the column except for the header row we delete the entire column. If
that's correct then try this macro

Sub Del_Cols()
Dim Col As Long
Set sht = Sheets("Sheet1")
For Col = sht.UsedRange.Columns.Count To 1 Step -1
If sht.Cells(Rows.Count, Col).End(xlUp).Row = 1 Then
Columns(Col).EntireColumn.Delete
End If
Next
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top