J. Wichtner
J. Wichtner

Reputation: 19

VBA convert date to a number based on text box input

I have a userform I am making. An input box will open and the user will enter a month. Then The userform will open, inputting that month into textbox3. I want text box 1 to be 1&the number form of that month. I have tried several types of code but i am fairly new to vba.

Help would be appreciated. Here is the code i have tried.

TextBox1=MONTH(DATEVALUE("1"&TextBox2.value))

Upvotes: 0

Views: 761

Answers (1)

user4039065
user4039065

Reputation:

With December in TextBox2, use,

 TextBox1 = "1" & Month(DateValue("1-" & TextBox2.value))

TBH, I really wouldn't trust my users to spell the month name correctly but have them select from a list instead.

Upvotes: 2

Related Questions