Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting empty cells in Excel

Status
Not open for further replies.

traceyr

Technical User
Aug 16, 2002
41
DE
I have a large spreadsheet (20 cols x 16,000 rows) which represents a hierarchical cost centre structure; the parent cost centre is in col 1 and the children across the page. Where a level is not present there is an empty cell.

I would like to process each row, deleting empty cells and shifting all remaining cells to the left.
When it is finished I need to export the result as a csv, if possible without trailing commas.

Is this possible with an Excel macro?
Any ideas anyone?
Thanks in advance for your help.
Tracey
 
To get rid of the blanks you could use this macro to get rid of the blanks.

Sub DeleteBlanks()
Dim cell
For Each cell In Selection
cell.Select
If ActiveCell = "" Then
Selection.Delete Shift:=xlToLeft
End If
Next
End Sub

Just highlight the range of data you wish to perform the action on and run the macro.


HTH,
Eric
 
Or even just select the area concerned, do Edit / Go To / Special / Blank Cells Only, then do Edit / Delete / Shift Cells left.

Regards
Ken................
 
Eric,

Thanks. It does the job well :) (but slowly! :-( )

Tracey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top