Using SpinControl to update date value in a form

traversd

Board Regular
Joined
Mar 17, 2002
Messages
82
Hi,

Does anyone know where to start with using Spinbuttons ?

I want to use a spinbutton to change the day value in in a textbox that holds the current date. But have no idea where to start ! Any help would be great !

Cheers
Darren
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Howdy, I have a very similar thing going on at the moment. If you Private message me your email address, I'll send you a spin button that does the days of week
 
Upvote 0
Alternatively, just select spin button from the Control Toolbox toolbar, draw it on your page, then right click and go to Properties. In the field marked Linked Cell, put the cell rreference you want it to connect to (E.g: A2) then set Max Length to about 10,000,000 to give yourself plenty of range. Now close the Properties window and take yourself out of design mode. Now right click on the cell you linked to, and pick Format Cells.

Go to the Number tab and choose Date from the menu, and pick the type of date format you want to use. Hey presto
 
Upvote 0
Hi Darren


Paste this in the UserForm Private module, just change the names to suit.

Option Explicit
Dim dDate As Date

Private Sub SpinButton1_SpinDown()
dDate = DateValue(TextBox1.Value) - 1
TextBox1 = Format(dDate, "dd mmm yyyy")
End Sub

Private Sub SpinButton1_SpinUp()
dDate = DateValue(TextBox1.Value) + 1
TextBox1 = Format(dDate, "dd mmm yyyy")
End Sub

Private Sub UserForm_Initialize()
TextBox1 = Format(Date, "dd mmm yyyy")
End Sub

It would be a very good idea to set the "Locked" Property of TextBox1 to False while in the VBE.

_________________
Kind Regards
Dave Hawley
OzGrid Business Applications
Microsoft Excel/VBA Training
OzGrid.BusApp.170x45.gif

This message was edited by Dave Hawley on 2002-03-25 06:31
 
Upvote 0

Forum statistics

Threads
1,214,524
Messages
6,120,049
Members
448,940
Latest member
mdusw

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