PC Review


Reply
Thread Tools Rate Thread

Calendar Control -> Switch to Sheet X

 
 
DartCatch14
Guest
Posts: n/a
 
      7th Apr 2008
I am trying to allow a user to select a date from a Calendar Control, then
based upon the user's selection, move to a specific Sheet

Here is my code so far

Private Sub Calendar1_Click()
ActiveCell = Calendar1.Value
ActiveCell.NumberFormat = "mm/dd/yyyy"
If ActiveCell.Value = "04/12/2008" Then
Sheets("Week 2").Select
End If
Unload Me
End Sub

When the user selects 04/12/2008, the active cell changes, but the cursor
stays on this cell and the user does not go to Sheet, "Week 2".

Any ideas? Suggestions?

thanks

 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      8th Apr 2008
Try..
If ActiveCell.Text = "04/12/2008" Then
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"DartCatch14"
wrote in message
I am trying to allow a user to select a date from a Calendar Control, then
based upon the user's selection, move to a specific Sheet
Here is my code so far

Private Sub Calendar1_Click()
ActiveCell = Calendar1.Value
ActiveCell.NumberFormat = "mm/dd/yyyy"
If ActiveCell.Value = "04/12/2008" Then
Sheets("Week 2").Select
End If
Unload Me
End Sub

When the user selects 04/12/2008, the active cell changes, but the cursor
stays on this cell and the user does not go to Sheet, "Week 2".
Any ideas? Suggestions?
thanks

 
Reply With Quote
 
DartCatch14
Guest
Posts: n/a
 
      11th Apr 2008
Thanks, Jim, but for future programming support, I have moved away from hard
coding specific days as in my initial code (=4/13, =4/14, =4/15, etc.) to
something more easier to maintain going forward.

No matter what date a user selects from the Calendar Control, I have a
formula which computes the week ending Saturday date in the selected week -
this is working fine.

I know need to jump to a different sheet based upon the week ending Saturday
date.

Here is my code right now, but it returns a 1004 error message

Sub Calendar1_Click()
Range("P1").Select
'P1 is where the Calendar Control links the date
'Q1 is the computed Week Ending Saturday

If Range("Q1" = "4/5/2008") Then
Sheets("Week 1").Activate
ActiveWindow.Zoom = 75
ElseIf Range("Q1" = "4/12/2008") Then
Sheets("Week 2").Activate
ActiveWindow.Zoom = 75
Else
If Range("Q1" = "4/19/2008") Then
Sheets("Week 3").Activate
ActiveWindow.Zoom = 75
ElseIf Range("Q1" = "4/26/2008") Then
Sheets("Week 4").Activate
ActiveWindow.Zoom = 75
Else
If Range("Q1" = "5/3/2008") Then
Sheets("Week 5").Activate
ActiveWindow.Zoom = 75
ElseIf Range("Q1" = "5/10/2008") Then
Sheets("Week 6").Activate
ActiveWindow.Zoom = 75
Else
If Range("Q1" = "5/17/2008") Then
Sheets("Week 7").Activate
ActiveWindow.Zoom = 75
ElseIf Range("Q1" = "5/24/2008") Then
Sheets("Week 8").Activate
ActiveWindow.Zoom = 75
Else
If Range("Q1" = "5/31/2008") Then
Sheets("Week 9").Activate
ActiveWindow.Zoom = 75
ElseIf Range("Q1" = "6/7/2008") Then
Sheets("Week 10").Activate
ActiveWindow.Zoom = 75
Else
If Range("Q1" = "6/14/2008") Then
Sheets("Week 11").Activate
ActiveWindow.Zoom = 75
ElseIf Range("Q1" = "6/21/2008") Then
Sheets("Week 12").Activate
ActiveWindow.Zoom = 75
Else
If Range("Q1" = "6/28/2008") Then
Sheets("Week 13").Activate
ActiveWindow.Zoom = 75
End If
End If
End If
End If
End If
End If
End If
Unload Me


"Jim Cone" wrote:

> Try..
> If ActiveCell.Text = "04/12/2008" Then
> --
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
> (Excel Add-ins / Excel Programming)
>
>
> "DartCatch14"
> wrote in message
> I am trying to allow a user to select a date from a Calendar Control, then
> based upon the user's selection, move to a specific Sheet
> Here is my code so far
>
> Private Sub Calendar1_Click()
> ActiveCell = Calendar1.Value
> ActiveCell.NumberFormat = "mm/dd/yyyy"
> If ActiveCell.Value = "04/12/2008" Then
> Sheets("Week 2").Select
> End If
> Unload Me
> End Sub
>
> When the user selects 04/12/2008, the active cell changes, but the cursor
> stays on this cell and the user does not go to Sheet, "Week 2".
> Any ideas? Suggestions?
> thanks
>
>

 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      11th Apr 2008

Yes, you get errors when misplacing parentheses...
If Range("Q1" = "4/5/2008")
-should be-
If Range("Q1") = "4/5/2008"

However, I doubt that will work. See my first post.
There can be major differences between a cell's value and its displayed text.
The default property for a range is "Value". So omitting the property is setting
you up for failure in this case. A date is a numeric value not a text string.
4/5/2008 is actually carried in the cell as 39543.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"DartCatch14"
wrote in message
Thanks, Jim, but for future programming support, I have moved away from hard
coding specific days as in my initial code (=4/13, =4/14, =4/15, etc.) to
something more easier to maintain going forward.

No matter what date a user selects from the Calendar Control, I have a
formula which computes the week ending Saturday date in the selected week -
this is working fine.

I know need to jump to a different sheet based upon the week ending Saturday
date.

Here is my code right now, but it returns a 1004 error message

Sub Calendar1_Click()
Range("P1").Select
'P1 is where the Calendar Control links the date
'Q1 is the computed Week Ending Saturday

If Range("Q1" = "4/5/2008") Then
Sheets("Week 1").Activate
ActiveWindow.Zoom = 75
ElseIf Range("Q1" = "4/12/2008") Then
Sheets("Week 2").Activate
ActiveWindow.Zoom = 75
Else
If Range("Q1" = "4/19/2008") Then
Sheets("Week 3").Activate
ActiveWindow.Zoom = 75
ElseIf Range("Q1" = "4/26/2008") Then
Sheets("Week 4").Activate
ActiveWindow.Zoom = 75
Else
If Range("Q1" = "5/3/2008") Then
Sheets("Week 5").Activate
ActiveWindow.Zoom = 75
ElseIf Range("Q1" = "5/10/2008") Then
Sheets("Week 6").Activate
ActiveWindow.Zoom = 75
Else
If Range("Q1" = "5/17/2008") Then
Sheets("Week 7").Activate
ActiveWindow.Zoom = 75
ElseIf Range("Q1" = "5/24/2008") Then
Sheets("Week 8").Activate
ActiveWindow.Zoom = 75
Else
If Range("Q1" = "5/31/2008") Then
Sheets("Week 9").Activate
ActiveWindow.Zoom = 75
ElseIf Range("Q1" = "6/7/2008") Then
Sheets("Week 10").Activate
ActiveWindow.Zoom = 75
Else
If Range("Q1" = "6/14/2008") Then
Sheets("Week 11").Activate
ActiveWindow.Zoom = 75
ElseIf Range("Q1" = "6/21/2008") Then
Sheets("Week 12").Activate
ActiveWindow.Zoom = 75
Else
If Range("Q1" = "6/28/2008") Then
Sheets("Week 13").Activate
ActiveWindow.Zoom = 75
End If
End If
End If
End If
End If
End If
End If
Unload Me


"Jim Cone" wrote:
> Try..
> If ActiveCell.Text = "04/12/2008" Then
> --
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
> (Excel Add-ins / Excel Programming)





> "DartCatch14"
> wrote in message
> I am trying to allow a user to select a date from a Calendar Control, then
> based upon the user's selection, move to a specific Sheet
> Here is my code so far
>
> Private Sub Calendar1_Click()
> ActiveCell = Calendar1.Value
> ActiveCell.NumberFormat = "mm/dd/yyyy"
> If ActiveCell.Value = "04/12/2008" Then
> Sheets("Week 2").Select
> End If
> Unload Me
> End Sub
>
> When the user selects 04/12/2008, the active cell changes, but the cursor
> stays on this cell and the user does not go to Sheet, "Week 2".
> Any ideas? Suggestions?
> thanks

 
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
Switch lookup function to another sheet New2Macros Microsoft Excel Worksheet Functions 2 29th Jan 2010 05:28 PM
Switch to different sheet using cell value Dow Microsoft Excel Programming 4 19th Feb 2009 07:26 PM
Excel: Arrows scroll sheet instead of move cursor. How to switch =?Utf-8?B?VHVyZWx5IFRydWVseQ==?= Microsoft Excel Misc 2 31st Oct 2006 07:50 PM
Trying to switch to a different sheet in a macro? BigDave Microsoft Excel Programming 7 14th Jun 2005 06:44 PM
Macro to switch to another sheet, grab ref to any cell, paste ref in current sheet?? drhansenjr Microsoft Excel Misc 2 20th Nov 2004 05:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:00 PM.