Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA in Exel, well How to find an empty row

Status
Not open for further replies.

Crusader2

Technical User
Dec 29, 2002
11
EE
I have a simple exel worksheet, there're 2 rows not empty for example 2 first rows have some text in column A. How could I find an empty row (eg 3rd) and put there something.
 
Crusader,
To do this I named a range of cells "TestRange". then used this code. This works ONLY if everything in the range is text. If the cells contain numbers, then change the IF statement to look at the cells value. When it finds the next empty cell, that will be the one selected.

Sub FindNextEmptyCell()

Dim i As Integer
For i = 1 To Sheet1.Range("TestRange").Cells.Count - 1

If ActiveCell.Characters.Count > 0 Then
ActiveCell.Offset(1, 0).Activate
Else
MsgBox "This cell is empty"
Exit Sub
i = i + 1
End If
Next i
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top