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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

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
 

Forum statistics

Threads
1,181,745
Messages
5,931,783
Members
436,803
Latest member
Strycure12

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