PDA

View Full Version : Solved: Search for first open cell in Row



Mr.G
05-25-2009, 07:03 AM
Hi I need to find the first empty cell in a row ...

I first search with this this code down the column.

Sub Search()
Dim c
For Each c In Range("C:C").Cells
If c = "" Then
c.Select
Exit For
End If
Next
End Sub


So I want to search the ActiveCell row for first empty cell.

Thank you

Bob Phillips
05-25-2009, 07:42 AM
Sub Search
Cells(1, Activecell.Column).End(xlDown).Offset(1,0).Select
End Sub

Bob Phillips
05-25-2009, 07:43 AM
If you REALLY mean row, try


Sub Search
Cells(Activecell.Row, 1).End(xlDown).Offset(1,0).Select
End Sub

Mr.G
05-25-2009, 11:12 AM
The last one that searches the row gives a Run-time error 1004...

Won't that just select the next cell to the Active Cell?

Lets say that the first cell depending on entries could be in X or A or AB depending on amount of entries. So it should search the whole row until it finds the empty cell.

I am thinking something like..

Cells(Activecell.row) search
If value ="" then
cell.select

Could that be right?
Regards

Mr.G
05-25-2009, 12:05 PM
This seems to work
Do While ActiveCell.Offset(0, 1) <> ""
ActiveCell.Offset(0, 1).Activate
Loop

ActiveCell.Offset(0, 0).Value = TextBox2

thanks for the help.