Help needed to shift cells left if the cell to left of it is blank

djpotter

New Member
Joined
Nov 15, 2011
Messages
5
Hi all,

I need some help to solve a problem on an Excel 2007 spreadsheet.

Basically, I have 12 columns with 47571 rows in, and what I'd like to do is run a macro that will automatically check every cell to see if the cell to the left of it is blank, and if so, will move the data in that cell to the left to fill the blank cell.

So basically, it would tidy up the data in each row, eliminating all the blank cells while still keeping all the data in the same row. It doesn't matter that the data is shifting columns.

Any help would be greatly appreciated!

Thanks

David
djpotter@gmail DOT com
 
Welcome to the MrExcel board!

Test this on a copy of your workbook (or a smaller data set first).


Sub MoveLeft()
****ActiveSheet.UsedRange.SpecialCells(xlBlanks).Delete Shift:=xlToLeft
End Sub

As someone who has done some programming before, how would I be able to teach myself how do something like this outside of 'googling'? I've watched some VBA videos, and understand some basics, but I would never be able to figure this out on my own.
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Macro recorder actually worked quite well! But that was because I knew how to do this using point and click commands..
 
Upvote 0

Forum statistics

Threads
1,215,945
Messages
6,127,851
Members
449,411
Latest member
adunn_23

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