ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding a used / filled rows (https://www.excelbanter.com/excel-programming/418321-finding-used-filled-rows.html)

ogopogo5

Finding a used / filled rows
 
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 ***

Per Jessen

Finding a used / filled rows
 
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

"ogopogo5" skrev i meddelelsen
...
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 ***



ogopogo5

Finding a used / filled rows
 
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 ***

Gord Dibben

Finding a used / filled rows
 
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

On Thu, 09 Oct 2008 13:05:02 -0700, ogopogo5 wrote:

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 ***



ogopogo5

Finding a used / filled rows
 
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 ***


All times are GMT +1. The time now is 05:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com