Accumulative date stored in a caption

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,392
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have 14 boxes for a calander and above the each box is a label. I want to put the date of the first day in the fortnight above the caption of the first label. I then want it to auto fill to the other labels to add one day for each label so the date above each box represents the dates in the fortnight, starting from the date I enter above the first box. How would I do this?
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
By boxes you mean cells? Cells on a spreadsheet? Or boxes on a form?
Assuming you're putting a date in cell A1 and the cells continue on the same row...


in B1
=A1+1
copy along until row N
 
Upvote 0
I have an idea. I will enter the date in a cell below the boxes. I then copy them to a cell above the first box. From there, I can get the cells behind each box to be the right date but how do I get the label to be the value of the cell? I can't just use the cell as the label as the beginning of the cell does not coincide with the beginning of the box.

I am pretty sure I would need some vba here but I have no idea what.

Thanks,
Dave
 
Upvote 0
Assuming you have Userform with your Labels and "TextBoxes" on.
Perhaps this:-
NB: This code goes in the Userform Code Module.

When you show your userform you will get an "Input box" for your first date, then as the Userform loads the subsequent Labels will get their incremented dates.
Code:
Private [COLOR="Navy"]Sub[/COLOR] UserForm_Initialize()
[COLOR="Navy"]Dim[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] MyDt [COLOR="Navy"]As[/COLOR] Date
MyDt = InputBox("Enter Date", "Date", "Type your Date here")
[COLOR="Navy"]If[/COLOR] IsDate(MyDt) [COLOR="Navy"]Then[/COLOR]
    Me.Label1.Caption = MyDt
    [COLOR="Navy"]For[/COLOR] n = 2 To 14
        MyDt = DateAdd("d", 1, MyDt)
        UserForm1.Controls("Label" & n).Object.Caption = MyDt
    [COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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