Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default deleting cells

I have this report from SAP, where data is not allligned with plenty of
empty cells, all over. The purpose of this program is to delete all empty
cells (ONLY) so that the data which is on the right, move to the left, on
column.. It is over 28 columns and proceeding from the far right going
left. The problems I have are 1) the code will delete data and 2) it will
not reach first column. I don't understand why. Your help will be
appreciated.
Thanks
Daniel

' Proceeding by column, bring to the left all data by deleting empty
cells
For x = colIndex - 1 To 1 Step -1 'Column
For y = rowMax To 1 Step -1 'Row
If IsEmpty(Cells(y, x)) And found = False Then
found = True 'found the first cell of the range (to be
deleted)
startCell = y
ElseIf IsEmpty(Cells(y, x)) And found = True Then
ElseIf Not IsEmpty(Cells(y, x)) And found = True Then
endCell = y + 1 'found data so stop for this range
Range(Cells(startCell, x), Cells(endCell, x)).Select
Range(Cells(startCell, x), Cells(endCell, x)).Delete
Shift:=xlShiftToLeft
found = False 'reset to continue up in the column
End If
Next
Next


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Cells or Rows of Cells Nelly Excel Discussion (Misc queries) 3 August 22nd 07 11:46 AM
deleting cells JULZ New Users to Excel 1 August 21st 06 04:59 PM
deleting unused cells / getting rid of inactive cells Woody13 Excel Discussion (Misc queries) 3 January 26th 06 09:11 PM
Deleting cells KtM Excel Programming 4 December 23rd 05 12:06 PM
Deleting Hyphens or Dashes from multiple cells without deleting the remaining content rmaloy Excel Programming 5 February 9th 04 01:59 AM


All times are GMT +1. The time now is 12:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"