Add a day to a date issue

mmmreece

New Member
Joined
Apr 8, 2015
Messages
34
Hello. Back in the day I used to use the datepicker to enter dates but Microsoft realised that I'm now getting on in age it would be nice of them to retire the datepicker to help me towards retirement also. Now I no longer have the datepicker I have to use the dateadd function to add a day to a date but, unfortunately, this is seemingly impossible. Today the date is the 12th of September 2022 and I have spent all morning trying to add a button to a userform to add one day to the date in a hidden textbox and another button to subtract a day from the date in the hidden textbox. If I add it seems to be fine I'll get 13th of september but if I subtract I get some date in October. I tried my best to sort the issue out for myself but there are thousands of posts on google about people having similar issues with no solutions jumping out at me.
To simplify what I'm trying to achieve I'll explain a simplified version of the userform I have. Let's say there's four items. A visible datebox which shows the contents of a hidden textbox and 2 buttons. One button is to add one day to the date, the other is to subtract one day from the date. The date I'm working with is contained in the hidden textbox and the visible textbox shows a formatted version of the working date. Ie the hidden textbox will contain 12/9/2022 whereas the visible one will show "Mon 12-09-2022". I would like to be able to click on the command button labelled "+" to add a day and the command button labelled "-" to subtract a day. Have you any ideas how I can achieve this without the months and days swapping over as seems the default for Microsoft if the day is less than the 12th of the month?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try wrapping the date when used in CDate(),

For example:
VBA Code:
nDate = CDate(YourDate) + 1
VBA Code:
nDate = CDate(YourDate) - 1
 
Upvote 0
Try wrapping the date when used in CDate(),

For example:
VBA Code:
nDate = CDate(YourDate) + 1
VBA Code:
nDate = CDate(YourDate) - 1
Thanks for your reply. I apologise for my tone in my initial question but I've been getting a bit frustrated. I have tried using CDate but it doesn't seem to want to work. Unfortunately, I had a huge crash a week or so ago and lost lots of work and so my to do list has gone from being around 44 hours behind to being over 1400 hours behind and so I was hoping to automate my to do list spreadsheet and the frustration of it is that I'm now even farther behind. lol. Once I've finished moving all the records of my backlog to incomplete status I'll put up some dummy code for a userform for the issues I'm having. Thanks again for your very prompt reply.
 
Upvote 0

Forum statistics

Threads
1,224,788
Messages
6,180,955
Members
453,009
Latest member
lorbieckit

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