Loop through empty cells and data move to one cell left

AT BABU

Board Regular
Joined
Oct 12, 2018
Messages
54
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

Loop through empty cells and data move to one cell left
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO

<tbody>
</tbody>



Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO
Date11/6/2019Normal28035YNO

<tbody>
</tbody>
 
Last edited:

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try this

Code:
Sub Macro1()
  Range("B1:B" & Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft
End Sub
 
Upvote 0
Im glad to help you, thanks for the feedback.
 
Upvote 0
Code:
Sub Macro1()
  Range("B1:B" & Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft
End Sub
You can probably simplify your line of code safely to this...
Code:
[B:B].SpecialCells(xlBlanks).Delete Shift:=xlToLeft
as the SpecialCells function automatically limits its actions to the worksheet's UsedRange. (I said "safely" because under certain circumstances, the UsedRange can be larger than the displayed values, but that is unusual and deleting blanks from blank rows will not produce any errors.) Also note that I used xlBlanks instead of xlCellTypeBlanks... You can omit the CellType portion of the predefined constant arguments for the SpecialCells function and they will still work.
 
Last edited:
Upvote 0
Thanks Rick
85521263791736bfd534ca63896ea875.jpg
for the comments.
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,436
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top