PDA

View Full Version : Solved: Find Empty column



satyen
05-18-2008, 02:34 AM
Hi
Im using this to find an empty column in my worksheet,
colTmp = .Range(.Cells(1, 1), .Cells(1, 1).End(xlToRight)).Columns.Count + 1
But it finds the first empty cell in the column and thinks the whole column is empty, which is not the case.
Can anyone help me to ammend the code to ensure it looks at the whole column?

Many thanks

rbrhodes
05-18-2008, 02:58 AM
Hi satyen,

This seems to work:


coltmp = .UsedRange.Columns.Count + 1

Simon Lloyd
05-18-2008, 02:59 AM
This will find the last column with anything in then select the one next to it!

Sub FindLastColumn()
Dim LCol As Integer
If WorksheetFunction.CountA(Cells) > 0 Then
LCol = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
End If
ActiveSheet.Columns(LCol).Offset(0, 1).select
End Sub

satyen
05-18-2008, 03:15 AM
Perfec t Thanks guys!:thumb