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

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).
As long as you're not in column A, this should work:
ActiveCell.End(xlToLeft).Offset(0, -1).Select
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,094
Messages
6,123,071
Members
449,092
Latest member
ipruravindra

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