• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

last row used vba code

mahaveer

Member
i want to set a vba code for last used row in sheet1 if the value in column A is < 5 then open sheet2 otherwise open sheet3
 
Just try this :

[pre]
Code:
    With Worksheets(1)
Worksheets(3 + (.Cells(.UsedRange(.UsedRange.Count).Row, 1) < 5)).Activate
End With
[/pre]
 
Another way:

[pre]
Code:
With Worksheets("Sheet1")
If .Cells(.Rows.Count, "A").End(xlUp).Value2 < 5 Then
Worksheets("Sheet2").Select
Else
Worksheets("Sheet3").Select
End If
End With
[/pre]
 
Back
Top