column delete function urgent

K

Kranor

Hello all First post from me.
What I need is a function to check a large amount of imported Dat
(from SAP) for empty columns and then delete the empty ones. Hopefull
I could then combine this with a couple of macro's to get the inf
displayed how I want it. Any help greatly appreciate
 
T

Trevor Shuttleworth

One way:

Dim iLastColumn As Integer
Dim i As Integer
iLastColumn = ActiveCell.SpecialCells(xlLastCell).Column
For i = iLastColumn To 1 Step -1
If WorksheetFunction.CountA(Range(Cells(1, i), Cells(65536, i))) = 0
Then
MsgBox "Delete column " & i ' test
'Cells(1, i).EntireColumn.Delete ' live
End If
Next 'i

Switch on the "live" line when you're happy it is picking up the right
columns.

Regards

Trevor
 
M

Michael Chang

You could select a row, then from the Edit Menu, choose Go to, click on
Special, click on Blanks
Then right click on one of the resulting highlighted blank cells select
delete, entire column.

You could put it in a macro as:
Selection.SpecialCells(xlCellTypeBlanks).EntireColumn.Delete

Michael
 

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