Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spinner Button Change Value in Text Box By Formatted Date

Status
Not open for further replies.

PBAPaul

Programmer
Aug 3, 2002
140
GB
I wish to use VBA to change the value in the relevant text box in a full formatted value.

Change
Wednesday, 21 March 2018
With a spin to​
Thursday, 22 March 2018​

I have a spreadsheet calculation that I can use to show the day from the date but I want a single spin to be able to change the whole day/date format.

Thanks for your help.​
 
Since this is a VBA question, you should be asking this question in forum707

Anyway, try this:
[tt]Label1[/tt] and [tt]SpinButton1[/tt] controls on the Excel's UserForm:

Code:
Option Explicit
Dim dat As Date

Private Sub UserForm_Initialize()
dat = Now
Label1.Caption = Format(dat, "DDDD, DD MMMM YYYY")
End Sub

Private Sub SpinButton1_SpinDown()
Call SpinMyButton(-1)
End Sub

Private Sub SpinButton1_SpinUp()
Call SpinMyButton(1)
End Sub

Private Sub SpinMyButton(ByRef intS As Integer)
dat = DateAdd("d", intS, dat)
Label1.Caption = Format(dat, "DDDD, DD MMMM YYYY")
End Sub


---- Andy

There is a great need for a sarcasm font.
 
Dear Andrzejek
Thank you for your help. Sorry that I set this question in the wrong forum.
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top