Screen & Cursor Position after VBA Code Run

OldSwimmer1650

New Member
Joined
Dec 3, 2020
Messages
38
Office Version
  1. 365
Platform
  1. Windows
After a VBA macro run (runs every 1min) the macro stops and leaves me on a tab(one that I specified in the VBA code, call it "SummaryPage") but instead of being at cell A1(upper left corner) I'm many cells & columns off in blank cell space. If I select another tab then select the tab "SummaryPage" it places cell A1 in upper left corner.

When the code starts I save the name of the sheet I'm on
Currentsheet = ActiveSheet.Name 'this is sheet I'm currently on

The last lines of code
Sheets(Currentsheet).Select
Application.GoTo reference:=Range("A1"), scroll:=True
Range("a1").Select
Currentsheetcell.Activate
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Do you have events or other kinds of updates turned off in the rest of the code?

It seems like if you have
VBA Code:
Currentsheet = ActiveSheet

you could use:
VBA Code:
Application.Events = True
Currentsheet.Activate
Currentsheet.Range("A1").select
 
Upvote 0
The very last line of code that you have shown is
Rich (BB code):
Currentsheetcell.Activate
.. but you have not shown or told us how Currentsheetcell is defined or populated.



Sheets(Currentsheet).Select
Application.GoTo reference:=Range("A1"), scroll:=True
Range("a1").Select
Instead of those three lines all you should need is
VBA Code:
 Application.GoTo reference:=Sheets(Currentsheet).Range("A1"), scroll:=True
 
Upvote 0
Solution
Rich (BB code):
    Currentsheet = ActiveSheet.Name                     'this is sheet I'm currently on
    Set Currentsheetcell = ActiveCell
 
Upvote 0
Peter_SSs, tyvm for the help. It worked. It is contributors on this site like you that make it work! I know enough to be dangerous :), but I keep learning everyday from inputs like yours.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top