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 May 6th, 2002, 12:57 PM   #1
wzel
New Member
 
Join Date: May 2002
Posts: 9
Default

Is it possible to format a cell so that when it is clicked on, a drop down calendar displays and you can choose the date from the calendar to enter into the cell? If so, could someone describe the procedure. Thank You.
wzel is offline   Reply With Quote
Old May 6th, 2002, 01:04 PM   #2
Ricky Morris
Board Regular
 
Join Date: Mar 2002
Posts: 363
Default

Try:

Choose Data > Validation form the menu. Choose List from the Allow box. In the source box highlight a range on the spreadsheet which contains the data you would like to appear in your list.
__________________
It's never too late to learn something new.

Ricky
Ricky Morris is offline   Reply With Quote
Old May 6th, 2002, 05:54 PM   #3
dwhj
 
Join Date: May 2002
Posts: 20
Default

Alternatively, you could use Excel's calendar control.

Go to the VBE (Alt+F11), click on Tools>Additional Controls and look for Calendar Control 9.0.
Put this control on a UserForm and also put two spinner buttons and a command button.

Put the following in the UserForm code module :-

Private Sub CommandButton1_Click()
ActiveSheet.Range("A1") = Calendar1.Value
Me.Hide
End Sub

Private Sub SpinButton1_Change()
If Calendar1.Month = 12 And SpinButton1.Value > 0 Then
Calendar1.Year = Calendar1.Year + 1
Calendar1.Month = 1
ElseIf Calendar1.Month = 1 And SpinButton1.Value < 0 Then
Calendar1.Year = Calendar1.Year - 1
Calendar1.Month = 12
Else
Calendar1.Month = Calendar1.Month + SpinButton1.Value
End If
SpinButton1.Value = 0
End Sub

Private Sub SpinButton2_Change()
Calendar1.Year = Calendar1.Year + SpinButton2.Value
SpinButton2.Value = 0
End Sub


Put the following in the Worksheet's code module :-

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then UserForm1.Show
End Sub

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
UserForm1.Show
Target.Offset(1, 0).Select
End Sub


Now whenever cell A1 is selected or double-clicked, the calendar will appear so that a date can be selected and then entered in A1 by clicking the command button.










dwhj is offline   Reply With Quote
Old May 6th, 2002, 06:18 PM   #4
Fonged
New Member
 
Join Date: May 2002
Posts: 1
Default

Thanks for the post dwhj, I am trying to do it as well.

Could you make it a bit more dynamic - I need the calendar to come up and enter the date when any cell of a specific column is double clicked.

Thanks for the help.
Fonged is offline   Reply With Quote
Old May 6th, 2002, 07:30 PM   #5
dwhj
 
Join Date: May 2002
Posts: 20
Default

Quote:
On 2002-05-06 17:18, Fonged wrote:
Thanks for the post dwhj, I am trying to do it as well.

Could you make it a bit more dynamic - I need the calendar to come up and enter the date when any cell of a specific column is double clicked.

Thanks for the help.

Actually there was an error in the original code.
The BeforeDoubleClick procedure should have been :-

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$A$1" Then
UserForm1.Show
Application.EnableEvents = False
Target.Offset(1, 0).Select
Application.EnableEvents = True
End If
End Sub


If you want the calendar to appear, for example, when any cell in Column 2 (i.e. column B) is double-clicked :-

Private Sub CommandButton1_Click()
ActiveCell = Calendar1.Value
Me.Hide
End Sub

Private Sub SpinButton1_Change()
'MsgBox SpinButton1.Value
If Calendar1.Month = 12 And SpinButton1.Value > 0 Then
Calendar1.Year = Calendar1.Year + 1
Calendar1.Month = 1
ElseIf Calendar1.Month = 1 And SpinButton1.Value < 0 Then
Calendar1.Year = Calendar1.Year - 1
Calendar1.Month = 12
Else
Calendar1.Month = Calendar1.Month + SpinButton1.Value
End If
SpinButton1.Value = 0
End Sub

Private Sub SpinButton2_Change()
Calendar1.Year = Calendar1.Year + SpinButton2.Value
SpinButton2.Value = 0
End Sub

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 2 Then
UserForm1.Show
Target.Offset(1, 0).Select
End If
End Sub


In the BeforeDoubleClick procedure, just change the column number to fit your needs.



[ This Message was edited by: dwhj on 2002-05-06 18:36 ]
dwhj is offline   Reply With Quote
Old May 6th, 2002, 08:12 PM   #6
Eddie G.
Board Regular
 
Join Date: Feb 2002
Location: OKC
Posts: 98
Default

dwhj: This is cool, except when you click the spinner button to go in reverse, nothing happens, the forward button to increase the dates works fine.

Eddie G. is offline   Reply With Quote
Old May 7th, 2002, 01:59 AM   #7
dwhj
 
Join Date: May 2002
Posts: 20
Default

Quote:
On 2002-05-06 19:12, Eddie G. wrote:
dwhj: This is cool, except when you click the spinner button to go in reverse, nothing happens, the forward button to increase the dates works fine.

In the VBE go to the spin button properties window, and change the "Min" property from 0 to -1
dwhj is offline   Reply With Quote
Old May 7th, 2002, 06:49 AM   #8
smart
New Member
 
Join Date: May 2002
Posts: 1
Default

the Additional Controls it's unenable

how i can let Enable
really nice Topic

[ This Message was edited by: smart on 2002-05-07 05:51 ]
smart is offline   Reply With Quote
Old May 7th, 2002, 07:16 AM   #9
Rocky E
Board Regular
 
Join Date: Feb 2002
Location: North Alabama, USA
Posts: 105
Default

Hi Smart,
Did you Insert->User Form? It doesn't appear enabled until I do.


_________________
Hope this helps!

Rocky

"Be not the first by whom the New are try'd,
Nor yet the last to lay the Old aside."
Alexander Pope (1688-1744).

[ This Message was edited by: Rocky E on 2002-05-07 06:17 ]
Rocky E is offline   Reply With Quote
Old May 7th, 2002, 07:25 AM   #10
dwhj
 
Join Date: May 2002
Posts: 20
Default

Quote:
On 2002-05-07 05:49, smart wrote:
the Additional Controls it's unenable

how i can let Enable
really nice Topic

[ This Message was edited by: smart on 2002-05-07 05:51 ]

I'll assume you're using Excel 2000.

In the VBE, go to Tools>References and look in the drop down list for Microsoft Calendar Control 9.0
If it's there, select it.

If it's not there, create a reference by browsing to MSCAL.OCX
Then go to Tools>Additional Controls and activate Calendar Control 9.0


Note : If you are using Excel 97, you need to activate Calendar Control 8.0
dwhj 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 -4. The time now is 09:27 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes