PC Review


Reply
Thread Tools Rate Thread

activating the previous sheet

 
 
bramnizzle@gmail.com
Guest
Posts: n/a
 
      25th Nov 2007
I am trying to activate the previous sheet in my code. My macro does
some code from the current sheet but then needs to pull some
information from the previous sheet. I get an error when I insert the
line
ActiveSheet.Previous.Select
Is this not correct?
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      25th Nov 2007
It worked for me. What error did you get?

"(E-Mail Removed)" wrote:

> I am trying to activate the previous sheet in my code. My macro does
> some code from the current sheet but then needs to pull some
> information from the previous sheet. I get an error when I insert the
> line
> ActiveSheet.Previous.Select
> Is this not correct?
>

 
Reply With Quote
 
bramnizzle@gmail.com
Guest
Posts: n/a
 
      25th Nov 2007
On Nov 25, 3:37 pm, JLGWhiz <JLGW...@discussions.microsoft.com> wrote:
> It worked for me. What error did you get?
>
> "bramniz...@gmail.com" wrote:
> > I am trying to activate the previous sheet in my code. My macro does
> > some code from the current sheet but then needs to pull some
> > information from the previous sheet. I get an error when I insert the
> > line
> > ActiveSheet.Previous.Select
> > Is this not correct?


I changed things around...I think it is because my previous sheet was
hidden.
 
Reply With Quote
 
bramnizzle@gmail.com
Guest
Posts: n/a
 
      25th Nov 2007
On Nov 25, 3:37 pm, JLGWhiz <JLGW...@discussions.microsoft.com> wrote:
> It worked for me. What error did you get?
>
> "bramniz...@gmail.com" wrote:
> > I am trying to activate the previous sheet in my code. My macro does
> > some code from the current sheet but then needs to pull some
> > information from the previous sheet. I get an error when I insert the
> > line
> > ActiveSheet.Previous.Select
> > Is this not correct?


The previous sheet was a hidden sheet. I think that is why it would
not work. I inserted
ActiveSheet.Previous.Visible = True
ActiveSheet.Previous.Select
and I didn't get an error...however, my code did not do what I wanted
it to. Back to the drawing board!
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      25th Nov 2007
First, you don't usually have to .select or .activate a sheet to work on it.

But this may do what you want:

Option Explicit
Sub testme()
Dim sCtr As Long
Dim FoundIt As Boolean
FoundIt = False
For sCtr = ActiveSheet.Index - 1 To 1 Step -1
If Sheets(sCtr).Visible = True Then
Sheets(sCtr).Select
FoundIt = True
Exit For
End If
Next sCtr

If FoundIt = False Then
MsgBox "Error showing previous sheet"
End If
End Sub



(E-Mail Removed) wrote:
>
> On Nov 25, 3:37 pm, JLGWhiz <JLGW...@discussions.microsoft.com> wrote:
> > It worked for me. What error did you get?
> >
> > "bramniz...@gmail.com" wrote:
> > > I am trying to activate the previous sheet in my code. My macro does
> > > some code from the current sheet but then needs to pull some
> > > information from the previous sheet. I get an error when I insert the
> > > line
> > > ActiveSheet.Previous.Select
> > > Is this not correct?

>
> The previous sheet was a hidden sheet. I think that is why it would
> not work. I inserted
> ActiveSheet.Previous.Visible = True
> ActiveSheet.Previous.Select
> and I didn't get an error...however, my code did not do what I wanted
> it to. Back to the drawing board!


--

Dave Peterson
 
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
transfer contents from a cell in previous sheet if the sheet is a DarkNight Microsoft Excel New Users 1 9th Sep 2008 01:04 AM
Copying the repeated data of the previous sheet to the next sheet =?Utf-8?B?U2FzaWtpcmFu?= Microsoft Excel Misc 1 25th Sep 2007 03:18 PM
Select sheet, Pause till Enter pressed, return to previous sheet Russ3Z Microsoft Excel Programming 1 12th Jun 2007 11:06 PM
Animation doesn't work after activating previous action button =?Utf-8?B?RXBpbm4=?= Microsoft Powerpoint 2 11th Jul 2006 01:16 PM
Help with activating previous sheet johncassell Microsoft Excel Programming 1 10th May 2006 06:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:45 PM.