need help with short & sweet macro

ginahoy

New Member
Joined
Sep 26, 2004
Messages
36
I rarely use macros so when I need one, I can never remember any of the syntax. I'd be grateful if someone could assist with building a macro that implements this pseudocode and add to the context menu:

> search selected column for empty cells and delete and shift cells left if empty

thx
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
How about:

VBA Code:
Sub SelectedColumnDeleteBlanksShiftLeft()
    Columns(Split(Cells(1, ActiveCell.Column).Address, "$")(1)).SpecialCells(xlCellTypeBlanks).Delete shift:=xlToLeft
End Sub
 
Last edited:
Upvote 0
Above is too heavy, try this instead

VBA Code:
Sub jec()
ActiveSheet.UsedRange.Columns(ActiveCell.Column).SpecialCells(4).Delete xlToLeft
End Sub
 
Upvote 0
Or even
VBA Code:
ActiveCell.EntireColumn.SpecialCells(xlBlanks).Delete xlToLeft
 
Upvote 0
Solution
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,490
Members
448,967
Latest member
visheshkotha

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