PC Review


Reply
Thread Tools Rate Thread

Back to Previous Sheet (Leo)

 
 
=?Utf-8?B?TGVv?=
Guest
Posts: n/a
 
      9th Oct 2007
Hi,
In an individual large workbook, I put these codes in ThisWorkbook module to
get back previous sheet I navigate;

Public CurrentSheet As Worksheet

Private Sub Workbook_Open()
Application.OnKey "^+B", "thisworkbook.GoBack"
End Sub

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Set CurrentSheet = Sh
End Sub

Public Sub GoBack()
If Not CurrentSheet Is Nothing Then CurrentSheet.Activate
End Sub

so when I move to another sheet in a large workbook containing many sheets,
I can go back to previous one just by pressing Ctrl+Shif+B.
This works fine for an individual workbook, but when I tried to copy the
same on my AddIn to use it for all open or new workbooks, it failed, and the
code did nothing. It seems that CurrentSheet Variable is always Nothing.
I appreciate if you would tell me what is wrong, and how can I fix it??!
--
Thans & Best regards
Leo, InfoSeeker
 
Reply With Quote
 
 
 
 
JW
Guest
Posts: n/a
 
      9th Oct 2007
If you have that code in the ThisWorkbook module of your addin, then
it will only work in that addin. Sounds to me like this might call
for a class module at the application level.
Chip has a nice page dedicated to class modules. Have a look.
http://cpearson.com/excel/Classes.aspx

Leo wrote:
> Hi,
> In an individual large workbook, I put these codes in ThisWorkbook module to
> get back previous sheet I navigate;
>
> Public CurrentSheet As Worksheet
>
> Private Sub Workbook_Open()
> Application.OnKey "^+B", "thisworkbook.GoBack"
> End Sub
>
> Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
> Set CurrentSheet = Sh
> End Sub
>
> Public Sub GoBack()
> If Not CurrentSheet Is Nothing Then CurrentSheet.Activate
> End Sub
>
> so when I move to another sheet in a large workbook containing many sheets,
> I can go back to previous one just by pressing Ctrl+Shif+B.
> This works fine for an individual workbook, but when I tried to copy the
> same on my AddIn to use it for all open or new workbooks, it failed, and the
> code did nothing. It seems that CurrentSheet Variable is always Nothing.
> I appreciate if you would tell me what is wrong, and how can I fix it??!
> --
> Thans & Best regards
> Leo, InfoSeeker


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select sheet, Pause till Enter pressed, return to previous sheet Russ3Z Microsoft Excel Programming 1 12th Jun 2007 11:06 PM
back to previous sheet =?Utf-8?B?TWlyaQ==?= Microsoft Excel Programming 1 29th Jan 2007 07:07 AM
How do I get the Hyperlink back button to go back to the previous. =?Utf-8?B?TUJ0aG9tUjk=?= Microsoft Word Document Management 0 23rd Sep 2004 08:39 PM
IE 6 navigates back to previous page by itself (as if I had clicked the 'back' button) Nelson Windows XP Internet Explorer 0 26th Jul 2004 06:34 PM
Link back to previous page before and after post back =?Utf-8?B?VGlt?= Microsoft Dot NET 0 10th May 2004 08:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:08 AM.