Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Bringing focus back to source point upon subroutine run completion

Hi guys,

Let's say I'm working in Sheet13 with cursor on B3

Using Alt+F8, I call / run a sub from my personal.xls, for example:

Sub SwitchOffGridLinesWS()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
ActiveWindow.DisplayGridlines = False
Next
End Sub

The sub finishes its job but the activesheet has changed
to the rightmost sheet's cell A1

How do I bring the cursor focus back to where I was when I ran the sub:
i.e. back to Sheet13 with cursor on B3 ?

Thanks for insights.
--
Rgds
Max
xl 97
---
Please respond, in newsgroup
xdemechanik <atyahoo<dotcom
----


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Bringing focus back to source point upon subroutine run completion

Sub SwitchOffGridLinesWS()
Dim ws As Worksheet
Dim wsht as Worksheet
Set wsht=activesheet
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
ActiveWindow.DisplayGridlines = False
Next
wsht.select
End Sub

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

Hi guys,

Let's say I'm working in Sheet13 with cursor on B3

Using Alt+F8, I call / run a sub from my personal.xls, for example:

Sub SwitchOffGridLinesWS()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
ActiveWindow.DisplayGridlines = False
Next
End Sub

The sub finishes its job but the activesheet has changed
to the rightmost sheet's cell A1

How do I bring the cursor focus back to where I was when I ran the sub:
i.e. back to Sheet13 with cursor on B3 ?

Thanks for insights.


  #3   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Bringing focus back to source point upon subroutine run completion

Thanks, Paul !
Works great.
--
Rgds
Max
xl 97
---
Please respond, in newsgroup
xdemechanik <atyahoo<dotcom
----
wrote in message
...
Sub SwitchOffGridLinesWS()
Dim ws As Worksheet
Dim wsht as Worksheet
Set wsht=activesheet
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
ActiveWindow.DisplayGridlines = False
Next
wsht.select
End Sub

HTH
Paul



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Bringing focus back to source point upon subroutine run completion

Here is one way
Sub SwitchOffGridLinesWS()
Dim ws As Worksheet, MyWs as Worksheet, MyRng as Rang
Set MyWs as ActiveShee
Set MyRng = Selectio
For Each ws In ActiveWorkbook.Worksheet
ws.Activat
ActiveWindow.DisplayGridlines = Fals
Nex
MyWs.Activat
MyRng.Selec
End Su


----- Max wrote: ----

Hi guys

Let's say I'm working in Sheet13 with cursor on B

Using Alt+F8, I call / run a sub from my personal.xls, for example

Sub SwitchOffGridLinesWS(
Dim ws As Workshee
For Each ws In ActiveWorkbook.Worksheet
ws.Activat
ActiveWindow.DisplayGridlines = Fals
Nex
End Su

The sub finishes its job but the activesheet has change
to the rightmost sheet's cell A

How do I bring the cursor focus back to where I was when I ran the sub
i.e. back to Sheet13 with cursor on B3

Thanks for insights
-
Rgd
Ma
xl 9
--
Please respond, in newsgrou
xdemechanik <atyahoo<dotco
---



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Bringing focus back to source point upon subroutine run completion



----- chris wrote: ----

Here is one way
Sub SwitchOffGridLinesWS()
Dim ws As Worksheet, MyWs as Worksheet, MyRng as Rang
Set MyWs = ActiveShee
Set MyRng = Selectio
For Each ws In ActiveWorkbook.Worksheet
ws.Activat
ActiveWindow.DisplayGridlines = Fals
Nex
MyWs.Activat
MyRng.Selec
End Su



----- Max wrote: ----

Hi guys

Let's say I'm working in Sheet13 with cursor on B

Using Alt+F8, I call / run a sub from my personal.xls, for example

Sub SwitchOffGridLinesWS(
Dim ws As Workshee
For Each ws In ActiveWorkbook.Worksheet
ws.Activat
ActiveWindow.DisplayGridlines = Fals
Nex
End Su

The sub finishes its job but the activesheet has change
to the rightmost sheet's cell A

How do I bring the cursor focus back to where I was when I ran the sub
i.e. back to Sheet13 with cursor on B3

Thanks for insights
-
Rgd
Ma
xl 9
--
Please respond, in newsgrou
xdemechanik <atyahoo<dotco
---





  #6   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Bringing focus back to source point upon subroutine run completion

Thanks, Chris !
Works great ..
--
Rgds
Max
xl 97
---
Please respond, in newsgroup
xdemechanik <atyahoo<dotcom
----
"chris: correction" wrote in message
...


----- chris wrote: -----

Here is one way:
Sub SwitchOffGridLinesWS()
Dim ws As Worksheet, MyWs as Worksheet, MyRng as Range
Set MyWs = ActiveSheet
Set MyRng = Selection
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
ActiveWindow.DisplayGridlines = False
Next
MyWs.Activate
MyRng.Select
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vlookup bringing back #N/A Afsha Excel Discussion (Misc queries) 2 July 5th 07 01:19 PM
Bringing quotations back up on screen flymeoutofhere Excel Discussion (Misc queries) 1 October 2nd 06 01:55 PM
How do I get focus back on an Excel file? Stumpiana Charts and Charting in Excel 1 November 18th 05 01:21 AM
Change focus from Userform back to Sheet rocketslinger[_2_] Excel Programming 5 January 11th 04 02:31 PM
Focus back from modeless userform to sheet RB Smissaert Excel Programming 4 September 5th 03 04:21 PM


All times are GMT +1. The time now is 11:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"