0

I want to find a last row with data within a range. for example i want to find a last empty row in range("A15:A42"). it should not go beyond A42. Any help.

lRow = Range("C15:C42").End(xlDown).Row   ....it goes beyond C42..

IMP Info copied from comments

yes ..i will have some other data from C43 ... – user2703472 3 hours ago

4
  • Maybe it's already done but you have to check your data first, are you sure that no value is present under line 42 in your column C ? Commented Nov 6, 2013 at 9:48
  • Also check if you are referencing in the correct sheet? the result of the code you posted vary depending on which sheet is selected. Commented Nov 6, 2013 at 9:56
  • yes ..i will have some other data from C43 ... Commented Nov 6, 2013 at 9:56
  • Yes i tried with Activesheet.Range. but it goes beyond c42 and gives me a row nr like 1026 Commented Nov 6, 2013 at 9:58

1 Answer 1

4

Is this what you are trying? I am assuming that C15 has data.

Option Explicit

Sub sample()
    Dim ws As Worksheet
    Dim rng As Range
    Dim LRow As Long

    '~~> Change this to the relevant sheet
    Set ws = ThisWorkbook.Sheets("Sheet1")

    With ws
        Set rng = .Range("C15:C42")

        LRow = .Range(Split(.Cells(, rng.Column).Address, "$")(1) & _
               (rng.Row + rng.Rows.Count)).End(xlUp).Row

        Debug.Print LRow
    End With
End Sub

ScreenShot:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.