mahaveer Member Dec 15, 2012 #1 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
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
Marc L Excel Ninja Dec 15, 2012 #2 Just try this : [pre] Code: With Worksheets(1) Worksheets(3 + (.Cells(.UsedRange(.UsedRange.Count).Row, 1) < 5)).Activate End With [/pre]
Just try this : [pre] Code: With Worksheets(1) Worksheets(3 + (.Cells(.UsedRange(.UsedRange.Count).Row, 1) < 5)).Activate End With [/pre]
Colin Legg Active Member Dec 16, 2012 #3 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]
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]