Porschemaniac
Technical User
Something that I am currently working on requires a date to be input. Ideally, I will then be using this date as a variable, for use in some other VBA macros.
Having read many, many online tips (and after consulting my Excel VBA for Dummies), I have managed to get a calendar working.
I have inserted a User Form, with a Calendar control. I have successfully managed to call this from a worksheet, using a command button and have inserted the neccessary code into both the worksheet and User Form (code to call in worksheet - UserForm.1 Show) and I have also inserted code directly into the User Form to control two embedded control buttons (OK and Cancel).
All of the examples that I have found read the date from the User Form directly into a cell, using Active.Cell = UserForm1.Calendar1.Value. However, I need to take the UserForm1.Calendar1.Value and read it into a variable called Lrd (Last Review Date).
I have added the line Lrd = UserForm1.Calendar1.Value into the worksheet, where I need to use the date variable (after the line UserForm1.Show) However, when the User Form activates, I am able to select dates, usng the calendar, however, the date does not seem to populate into the Lrd variable.
In fact, what actually happens is that Lrd populates as the date last set when editing the Calendar User Form in the VB Editor.
I know the value is in there somewhere, I just need to figure out how to get it into my Lrd Variable.
As always, any help will be greatly appreciated.
Thanks,
Ian.
Having read many, many online tips (and after consulting my Excel VBA for Dummies), I have managed to get a calendar working.
I have inserted a User Form, with a Calendar control. I have successfully managed to call this from a worksheet, using a command button and have inserted the neccessary code into both the worksheet and User Form (code to call in worksheet - UserForm.1 Show) and I have also inserted code directly into the User Form to control two embedded control buttons (OK and Cancel).
All of the examples that I have found read the date from the User Form directly into a cell, using Active.Cell = UserForm1.Calendar1.Value. However, I need to take the UserForm1.Calendar1.Value and read it into a variable called Lrd (Last Review Date).
I have added the line Lrd = UserForm1.Calendar1.Value into the worksheet, where I need to use the date variable (after the line UserForm1.Show) However, when the User Form activates, I am able to select dates, usng the calendar, however, the date does not seem to populate into the Lrd variable.
In fact, what actually happens is that Lrd populates as the date last set when editing the Calendar User Form in the VB Editor.
I know the value is in there somewhere, I just need to figure out how to get it into my Lrd Variable.
As always, any help will be greatly appreciated.
Thanks,
Ian.