Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Delete Blank Cells in a Row

I have 8000+ rows of data where each row has bank cells in random positions,
except for Column A which is aways populated.

Can someone help me with a script that will check each row, delete the bank
cell by moving the other cells in the row to the left.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,480
Default Delete Blank Cells in a Row

Hi Charles

You don't actually need a script.
Select you whole range of dataF5SpecialBlankOKright clickDeleteShift
cells left.

--
Regards
Roger Govier

"Charles" wrote in message
...
I have 8000+ rows of data where each row has bank cells in random
positions,
except for Column A which is aways populated.

Can someone help me with a script that will check each row, delete the
bank
cell by moving the other cells in the row to the left.

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Delete Blank Cells in a Row

Sub squeezeBlanks()
Dim n As Long, i As Long
Dim j As Long
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To n
k = Cells(i, Columns.Count).End(xlToLeft).Column
For j = k To 2 Step -1
With Cells(i, j)
If IsEmpty(.Value) Then
.Delete Shift:=xlToLeft
End If
End With
Next
Next
End Sub

--
Gary''s Student - gsnu200837
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Delete Blank Cells in a Row

Untested

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long, j As Long
Dim LastRow As Long
Dim LastCol As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To LastRow

LastCol = .Cells(i, .Columns.Count).End(xlToLeft).Column
For j = LastCol To 2 Step -1

If .Cells(i, j).Value = "" Then

.Cells(i, j).Delete Shift:=xlToLeft
End If
Next j
Next i
End With

End Sub

--
__________________________________
HTH

Bob

"Charles" wrote in message
...
I have 8000+ rows of data where each row has bank cells in random
positions,
except for Column A which is aways populated.

Can someone help me with a script that will check each row, delete the
bank
cell by moving the other cells in the row to the left.

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Delete Blank Cells in a Row

Hi
This works very well, but it is looping at the "End If" statement

Regards

Charles

"Gary''s Student" wrote:

Sub squeezeBlanks()
Dim n As Long, i As Long
Dim j As Long
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To n
k = Cells(i, Columns.Count).End(xlToLeft).Column
For j = k To 2 Step -1
With Cells(i, j)
If IsEmpty(.Value) Then
.Delete Shift:=xlToLeft
End If
End With
Next
Next
End Sub

--
Gary''s Student - gsnu200837



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Delete Blank Cells in a Row

Hi Roger

Thanks, a neat and simple solultion. I must make more use of F5.

Regards

Charles

"Roger Govier" wrote:

Hi Charles

You don't actually need a script.
Select you whole range of dataF5SpecialBlankOKright clickDeleteShift
cells left.

--
Regards
Roger Govier

"Charles" wrote in message
...
I have 8000+ rows of data where each row has bank cells in random
positions,
except for Column A which is aways populated.

Can someone help me with a script that will check each row, delete the
bank
cell by moving the other cells in the row to the left.

Thanks



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Delete Blank Cells in a Row

Hi Bob

This also works. Thank you, all all the experts who reply so quickly and
concisely.

Regards

Charles

"Bob Phillips" wrote:

Untested

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long, j As Long
Dim LastRow As Long
Dim LastCol As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To LastRow

LastCol = .Cells(i, .Columns.Count).End(xlToLeft).Column
For j = LastCol To 2 Step -1

If .Cells(i, j).Value = "" Then

.Cells(i, j).Delete Shift:=xlToLeft
End If
Next j
Next i
End With

End Sub

--
__________________________________
HTH

Bob

"Charles" wrote in message
...
I have 8000+ rows of data where each row has bank cells in random
positions,
except for Column A which is aways populated.

Can someone help me with a script that will check each row, delete the
bank
cell by moving the other cells in the row to the left.

Thanks




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
how to delete blank cells between those with entries dumchik Excel Worksheet Functions 1 December 8th 08 05:13 AM
How do I Delete blank cells in a row Andy in Edinburgh[_2_] Excel Discussion (Misc queries) 3 September 5th 08 05:46 PM
delete error/blank cells Ask MS[_2_] Excel Worksheet Functions 3 June 30th 08 01:54 PM
Macro to Delete blank cells GarToms Excel Worksheet Functions 1 January 26th 06 07:39 PM
Macro to delete all blank cells Brian Excel Programming 2 December 15th 05 12:26 AM


All times are GMT +1. The time now is 06:00 AM.

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

About Us

"It's about Microsoft Excel"