column delete function urgent

  • Thread starter Thread starter Kranor
  • Start date Start date
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
 
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
 
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
 
Back
Top