When calendar populates, if date in associated cell, show date on calendar

MWhiteDesigns

Well-known Member
Joined
Nov 17, 2010
Messages
646
Office Version
  1. 2016
Platform
  1. Windows
Good afternoon,
I currently have a worksheet that when a user clicks on the cell, a calendar form opens. From here they can select a date, click ok, and the date gets placed in the corresponding cell they clicked on.

Now if the user needs to change that date, i want them to be able to click on the cell again, and when the calendar opens, the date in the cell would be selected on the calendar. I was able to do this in a userform, but im not sure how to edit it to work on the worksheet. I am using the below to populate the calendar.

Code:
private sub worksheet_selectionchange(byval target as range)
if not intersect(target,range("aa16:aa24")) is nothing then .show calendar

When the user clicks the date, the below code places it in the cell.

Code:
private sub ok_click()

with active cell
.value=calendar1.value
end with

unload me
end sub

Now the below code was used when I was using a userform, but im not sure how to edit this to pull the date from the active cell.

Code:
privatesub userform_activate()
me.calendar1=date
if not tb is nothing then
if isdate(tb.value)then me.calendar1.value = tb.value
end if
end sub

Any help would be greatly appreciated!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

MWhiteDesigns

Well-known Member
Joined
Nov 17, 2010
Messages
646
Office Version
  1. 2016
Platform
  1. Windows
Scratch that! I played around with this for a good hour before posting, however as soon as i clicked submit new thread, i figured it out. Please delete or keep this thread for future referece.

Code:
privatesub userform_activate()
me.calendar1=date
with activecell
if not activecell is nothing then
if isdate(.value)then me.calendar1.value = .value
end if
end with
end sub
 
Upvote 0

Forum statistics

Threads
1,195,662
Messages
6,011,002
Members
441,579
Latest member
satishrazdhan

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
Top