Macro help

Larry Fish

New Member
Joined
Jan 24, 2005
Messages
13
I know the steps on recording macros. I need a macro that will find the first blank column to the left of a column containing data.


Thanks for your help in advance.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Von Pookie

MrExcel MVP
Joined
Feb 17, 2002
Messages
13,686
As long as you're not in column A, this should work:
ActiveCell.End(xlToLeft).Offset(0, -1).Select
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
Hi

Range("IV1").End(xlToLeft).Column

is to find the first cell contains value from then right most column, Col.IV, on the 1st row.

so if you looking for the 1st empty cell, simply +1 will give you what you want.

hope this helps
jindon
 

chiello

Well-known Member
Joined
Jan 18, 2005
Messages
848
For Von Pookie
Sorry Von Pookie, :confused: :confused:
your solution works if you have contiguos data to the active cell. Infact, if cells immediately to the left are blank, those won't be selected.

For Larry

If you are looking for the first (entire) column blank, see below a possible solution.

Public Sub FirstBlankCol()
Dim DataCol As Long, LeftCol As Long
Dim ColFound As Boolean

ColFound = False
DataCol = 5 ' You know the right one
LeftCol = DataCol - 1

While LeftCol >= 1 And Not ColFound
With Columns(LeftCol)
If .SpecialCells(xlCellTypeBlanks).Count = .SpecialCells(xlCellTypeLastCell).Row Then
ColFound = True
.Select
Else
LeftCol = LeftCol - 1
End If
End With
Wend

End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,115
Messages
5,768,205
Members
425,459
Latest member
Danniey

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
Top