View Full Version : Solved: Range("A4").End(xlDown) Error
I am receiving an error using the following code. I've noticed, however, that the error only occurs if the worksheet, "Transactions," is not the active worksheet. Is there a way to make this line of code work properly regardless worksheet tab that is selected?
Worksheets("Transactions").Range("A4").End(xlDown).Select
Bob Phillips
03-23-2010, 09:03 AM
If transactions is not active, you cannot select a range in that sheet, you have to activate it first.
With Worksheets("Transactions")
.Activate
.Range("A4").End(xlDown).Select
End With
Paul_Hossler
03-23-2010, 09:14 AM
Do you really need to select it? You can use the cell without selecting it first, regardless of which sheet is active
myVar = Worksheets("Transactions").Range("A4").End(xlDown).value
Paul
If transactions is not active, you cannot select a range in that sheet, you have to activate it first.
With Worksheets("Transactions")
.Activate
.Range("A4").End(xlDown).Select
End With
Very good. Thanks, as always.
mdmackillop
03-23-2010, 10:58 AM
You can also use GoTo to select a range in the same or another open workbook.
Application.Goto Worksheets("Transactions").Range("A4").End(xlDown)
'or
Application.Goto Workbooks("Test.xls").Worksheets("Transactions").Range("A4").End(xlDown)
'or
Application.Goto Workbooks("Test.xls").Worksheets("Transactions").Range("Data")
You can also use GoTo to select a range in the same or another open workbook.
Application.Goto Worksheets("Transactions").Range("A4").End(xlDown)
'or
Application.Goto Workbooks("Test.xls").Worksheets("Transactions").Range("A4").End(xlDown)
Thanks.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.