MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Oct 24th, 2005, 06:47 PM   #1
UHsoccer
 
Join Date: Apr 2002
Location: Detroit
Posts: 636
Default

Found a reference to my problem elsewhere, I declared
"Public calendar1 as calendar"

The new code posted here brings up the calendar on a double -click, BUT there is still an error on the line with Calendar1 "Object variable or with block not set"

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim Cell1 As String, Cell2 As String
    Cell1 = "$F$20" 
    Cell2 = "$F$25"  
    If Target.Address = Cell1 Or Target.Address = Cell2 Then
        Load UserForm2
        UserForm2.Show
        ActiveCell.Value = Calendar1.Value  '  <<-- Error
        UserForm2.Hide
        Unload UserForm2
    End If
    
End Sub
Thanks in advance
UHsoccer is offline   Reply With Quote
Old Oct 24th, 2005, 07:07 PM   #2
TGM
 
Join Date: Jul 2005
Location: St. Albans, England
Posts: 47
Default

I haven't got a "calendar control" but I have used the "Microsoft Date and Time Picker Control 6.0 (SP4)" if this helps anyone.
Cheers Nimrod
__________________
Windows XP, Excel 2000
TGM is offline   Reply With Quote
Old Oct 25th, 2005, 11:36 AM   #3
cresswell80
 
Join Date: Oct 2005
Location: Leeds UK
Posts: 46
Default Re: Calander Problems

Quote:
Originally Posted by nanefy
Hi,

I have used the calander function below and it works perfectly. The only problem is that it doesnt, by default, bring up the current month. I implemented this in September and now in October it doesnt bring October up as the default date. Can anyone tell me how to do this?

Cheers!
Love this shortcut to calender but has anyone any ideas on nanefy's problem above???

thanks
__________________
Live The Dream!
cresswell80 is offline   Reply With Quote
Old Oct 25th, 2005, 01:11 PM   #4
D4VE
 
Join Date: Oct 2005
Location: Buggenhout
Posts: 1
Default

Try to add this code:

Private Sub UserForm_Activate()
Today = Now
Calendar1.Value = DateValue(Today)
End Sub
D4VE is offline   Reply With Quote
Old Oct 27th, 2005, 05:59 PM   #5
cresswell80
 
Join Date: Oct 2005
Location: Leeds UK
Posts: 46
Default

Quote:
Originally Posted by D4VE
Try to add this code:

Private Sub UserForm_Activate()
Today = Now
Calendar1.Value = DateValue(Today)
End Sub
sorry - where would you put this in the original code? i'm not the best at VB..
__________________
Live The Dream!
cresswell80 is offline   Reply With Quote
Old Oct 27th, 2005, 08:02 PM   #6
atmospheric
 
atmospheric's Avatar
 
Join Date: Jul 2002
Location: Leeds, UK
Posts: 517
Default

Found this example to be simple enough and worked for me (so it must be easy!):

http://www.ozgrid.com/VBA/excel-calendar-dates.htm

Also, there's an excellent tutorial here that includes adding a toolbar button and a menu item:

http://www.fontstuff.com/vba/vbatut07.htm
__________________
I got a sweater for Christmas. I really wanted a screamer or a moaner.
atmospheric is offline   Reply With Quote
Old Oct 28th, 2005, 01:29 PM   #7
UHsoccer
 
Join Date: Apr 2002
Location: Detroit
Posts: 636
Default

The step to put the calander on the user form (as described by Nimrod), has a problem when you want to distribute the spreadsheet to other users. You have to perform the steps shown below on each system!!!! I am expected to make my application available to about 100 unique users>

Is there another way besides the step below?

Second: Put calander on userform
1-In VBA window select the "toolbox"
2- Right click on "toolbox"
3- Select "additional controls" item from drop down menu
4- check/select "calender control" from the window that will appear
5- a calender object will appear on the "toolbox"
6- Drag and size the calender object from the "toolbox" to "userform1"
UHsoccer is offline   Reply With Quote
Old Apr 9th, 2006, 01:43 AM   #8
TheGhost
 
Join Date: Apr 2006
Posts: 6
Default WOW!

This is amazing! Thanks for the great instructions. They were perfect! (Except for my spelling)
__________________
Heeeeey - Like the Fonz
TheGhost is offline   Reply With Quote
Old Jan 19th, 2007, 08:13 AM   #9
rmtaylor
 
Join Date: Feb 2002
Location: Scotland
Posts: 139
Default

Thanks for sharing your knowledge.
I have been looking for this function for sometime it made my sheet more user friendly.

Robert
rmtaylor is offline   Reply With Quote
Old Jan 26th, 2007, 11:19 PM   #10
kyrgan
 
kyrgan's Avatar
 
Join Date: Mar 2006
Location: Eugene, Oregon
Posts: 296
Default

This is an awesome thread.
Anyone have input on how to format the date without using the cell format controls to guide the parameters of the date field?

I am looking at how to properly format the date into a variable to pass to SQL.

Gracias
kyrgan is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On

Forum Jump


All times are GMT +1. The time now is 11:21 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.