UserForms

RichardU

Board Regular
Joined
Aug 3, 2007
Messages
98
Hi there

I have never used UserForms and wanted to create one where the user could pick one of 2 choices. These choices are month names but need to be looked up based on todays date or a cell in a sheet. i.e.

Cell A1 = 31/07/2007
TodaysDate = 07/08/2007

UserForm to show like

Please select which file you want to open.

July August
o o

With selection boxes or something in the form and a OK button

How would i go about doing this?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
This is a horrible, horrible code but it seems to work. I'm sure someone can reduce it but I'm not feeling well so its all I can give!

A1 = 31/07/07
A2 = Today()

Code:
Private Sub UserForm_Activate()
Dim rn As Range
i = 1

Set rn = Range("a1:A2")
For Each Value In rn

If Mid(Value, 4, 2) = "01" Then Cells(i, 2).Value = "January"
If Mid(Value, 4, 2) = "02" Then Cells(i, 2).Value = "February"
If Mid(Value, 4, 2) = "03" Then Cells(i, 2).Value = "March"
If Mid(Value, 4, 2) = "04" Then Cells(i, 2).Value = "April"
If Mid(Value, 4, 2) = "05" Then Cells(i, 2).Value = "May"
If Mid(Value, 4, 2) = "06" Then Cells(i, 2).Value = "June"
If Mid(Value, 4, 2) = "07" Then Cells(i, 2).Value = "July"
If Mid(Value, 4, 2) = "08" Then Cells(i, 2).Value = "August"
If Mid(Value, 4, 2) = "09" Then Cells(i, 2).Value = "September"
If Mid(Value, 4, 2) = "10" Then Cells(i, 2).Value = "October"
If Mid(Value, 4, 2) = "11" Then Cells(i, 2).Value = "November"
If Mid(Value, 4, 2) = "12" Then Cells(i, 2).Value = "December"
i = i + 1

Next Value

ComboBox1.AddItem Range("b1").Value
ComboBox1.AddItem Range("b2").Value

End Sub

Home to bed :cry:
 
Upvote 0

Forum statistics

Threads
1,214,837
Messages
6,121,883
Members
449,057
Latest member
Moo4247

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