date picker

alcorjr

Active Member
Joined
Dec 29, 2002
Messages
416
Hi, on some programs I have seen, that when a date must be selected, you can do it through a button that opens uo a little calendar page on which you just click on the date selected.

Is there anything similar in Excel Office XP, or is this asking too much??

Thankyou all.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
excuse my ignorance, but I right-click on th toolbox bar, click on more controls, a list of optional controls unfold, but there's none called Ms calendar 10.0 I found one called Microsoft office Data Source COntrol 10.0.
I tried pasting it on the sheet, but it's a weird looking control that looks more like a thumbtack than anything, and nothing like a calendar.

What am I doing wrong???

HELP!! :( :(
 
Upvote 0
Couple of questions here, so one by one:

"Is there a way to make it work for a range of cells? And make the control appear only when one of those cells is selected?"

Yes. Having got used to the basic set-up, you need to control it with vba. Something like:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
     If Not Intersect(Target, [A1:A10]) Is Nothing Then
            Calendar1.Visible = True
     Else: Calendar1.Visible = False
    End If
End Sub

"i was trying to do a vlookup..."

For a reason that remains unclear, the calendar control returns a text string! Again, this can be fixed with some vba. If you've already got the control set up to only show when you're ina certain range of cells, then something like:



Code:
Private Sub Calendar1_Click()
    ActiveCell.NumberFormat = "dd/mm/yy"
    ActiveCell = Calendar1
    Calendar1.Visible = False
End Sub

should fix it.

However, vba's not really my area, so there mayh be alternative approaches / solutions / inaccuracies in my reply.
 
Upvote 0
Beautiful :0)

that works a treat....

VB not your area ! heheheh well your not bad my friend not bad at all.

Thank you

Mike
 
Upvote 0
Re: date picker (beware)

Hi Mike,

Just a word from experiences that I had using that Calendar control...

If you plan on others using your finish application then they must have that exact control registered on their machine. Furthermore, I found that you really can't count on that being the case.

To get around this I built a VBA user form Date Picker that after testing seems to work well every time. If interested in checking it out, send me your email address and I'll forward. It's small but powerful.

Good luck and best regards.

Phil
 
Upvote 0
PaddyD said:
Couple of questions here, so one by one:

"Is there a way to make it work for a range of cells? And make the control appear only when one of those cells is selected?"

Yes. Having got used to the basic set-up, you need to control it with vba. Something like:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
     If Not Intersect(Target, [A1:A10]) Is Nothing Then
            Calendar1.Visible = True
     Else: Calendar1.Visible = False
    End If
End Sub

Hi Paddy,
I am keen to figure out how to make the calendar only appear when the cell it links to is clicked on. I am not sure how to get this piece of code you've provided to do that.

The cell I am dealing with is: H9

Can you suggest what I do to make this happen?

Thanks a lot,

Jonathan
 
Upvote 0
Hi, Jonathan,

do you mean this ?
change this line
If Not Intersect(Target, [A1:A10]) Is Nothing Then
to
If Not Intersect(Target, [H9]) Is Nothing Then

kind regards,
Erik
 
Upvote 0
erik.van.geit said:
Hi, Jonathan,

do you mean this ?
change this line
If Not Intersect(Target, [A1:A10]) Is Nothing Then
to
If Not Intersect(Target, [H9]) Is Nothing Then

kind regards,
Erik
Hi Erik,
Nice to hear from you again.
I did try that before making that post and it didn't seem to do anything.
I've tried it again and now I get an error when I click the cell H9. It says:
"Compile error. Can't find project or library"
It then jumps to the debugger and has the [H9] highlighted.

Here's the code in full:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, [ H9 ]) Is Nothing Then
Calendar1.Visible = True
Else: Calendar1.Visible = False
End If
End Sub


Any idea what might cause that error?

J
 
Upvote 0
no :confused:
you shouldn't have spaces
If Not Intersect(Target, [H9]) Is Nothing
(I didn't put spaces, but making Bold added them)
but this doesn't trigger an error for me
perhaps use Range("H9")
 
Upvote 0

Forum statistics

Threads
1,216,165
Messages
6,129,235
Members
449,496
Latest member
Patupaiarehe

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top