ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Leaving the cursor at a known position on a worksheet (https://www.excelbanter.com/excel-programming/424495-leaving-cursor-known-position-worksheet.html)

John

Leaving the cursor at a known position on a worksheet
 
How do I correct the following code to not give a 1004 error:
NewStatusSheetName = "newsheetname"
....
Sheets(NewStatusSheetName).Range("$A$1").Select
....
My macro jumps between two sheets and I want to leave the cursor at the top
of the new sheet at the end. I found that the following works, but I don't
know if a Go To is the best solution:
Application.Goto Sheets(NewStatusSheetName).Range("$H$1")

I appreciate your help, -John

Per Jessen

Leaving the cursor at a known position on a worksheet
 
Hi

Set NewStatusSheet = Worksheets("NewSheetName")
NewStatusSheet.Range("$A$2").Select

or

NewStatusSheetName = "NewStatusSheet"
Worksheets(NewSheetName).Activate
Range("$A$2").Select

Hopes this helps.

---
Per

"John" skrev i meddelelsen
...
How do I correct the following code to not give a 1004 error:
NewStatusSheetName = "newsheetname"
....
Sheets(NewStatusSheetName).Range("$A$1").Select
....
My macro jumps between two sheets and I want to leave the cursor at the
top
of the new sheet at the end. I found that the following works, but I
don't
know if a Go To is the best solution:
Application.Goto Sheets(NewStatusSheetName).Range("$H$1")

I appreciate your help, -John




All times are GMT +1. The time now is 08:50 PM.

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