Remove Columns with header in row 1 but no data in remainder of co

B

BriLar1

How do I Remove Columns with header in row 1 but no data in remainder of
column?
I am using exported template spreadsheets that provide the header row ready
for data import to the spreadsheet then using this to do bulk import to SQL
database, but need to remove the blank columns were there is no data below
the header en mass. Can anyone give me tips on how this could be done either
using vb code or macros.
Thanking you in advance
 
M

merjet

Change the numbers if Excel 2007.

Sub Macro1()
Dim iCol As Integer
Dim iRow As Long
For iCol = 256 To 1 Step -1
iRow = Cells(65536, iCol).End(xlUp).Row
If iRow = 1 Then Columns(iCol).Delete
Next iCol
End Sub

Hth,
Merjet
 

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