Finding a used / filled rows

O

ogopogo5

How can I write a sub-routine that will look for a row that is used /
filled. I.E. rows C1 to C8 are empty and it keep skipping the empty rows
until it finds a row that is used / filled. In this case row C9 is used.



*** Sent via Developersdex http://www.developersdex.com ***
 
P

Per Jessen

Hi

Try this:

Sub FindUsedRow()
TargetCol = "C"
If Range(TargetCol & "1").Value = "" Then
UsedRow = Range(TargetCol & "1").End(xlDown).Row
Else
UsedRow = 1
End If
Debug.Print UsedRow
End Sub

Regards,
Per
 
O

ogopogo5

Hi Par
Thank you for taking your time in helping out. I copied and paste your
FindUsedRow, however it doesn't work. I've left rows C1 to C8 empty. Is
there someting else I should be doing?



*** Sent via Developersdex http://www.developersdex.com ***
 
G

Gord Dibben

You need to look in the Immediate window to see the 9

Or add a message box

Sub FindUsedRow()
TargetCol = "C"
If Range(TargetCol & "1").Value = "" Then
UsedRow = Range(TargetCol & "1").End(xlDown).Row
Else
UsedRow = 1
End If
MsgBox UsedRow
Debug.Print UsedRow
End Sub


Gord Dibben MS Excel MVP
 
O

ogopogo5

Thank you Gord. It works.
However, I'm sorry I should of indicated at the and of my request; Once
it has found the used / filled row, it will select that cell.

Ogopogo5

*** Sent via Developersdex http://www.developersdex.com ***
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top