UserForm TextBox Concatenate with a Date

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,341
Office Version
  1. 365
Platform
  1. Windows
I have three TextBoxes. Two have values where the user is entering information. But my third I want to autopopulate with data from the first two

The first one is "EscalationBaseDate" it is a date field (Example: 2021/12/15)

Code:
Private Sub EscalationBaseDate_Exit(ByVal Cancel As MSForms.ReturnBoolean)

    With EscalationBaseDate
        If IsDate(.Value) = True Then
            .Value = format(.Value, "YYYY/MM/DD")
        ElseIf .Value = "" Then
            .Value = .Value
        ElseIf IsDate(.Value) = False Then
            MsgBox "Enter a date", 48, "Invalid Entry"
            .Value = ""
            Cancel = True
        End If
    End With

End Sub
[code/]

The second is IHSEscCode Which is text (Example: PPI3359291)


My Third TexBox on my userform is called EscRate   I need to concatenate the first two but only using the year from the first one and a "-" placed in-between. 

So in this case the third text box would be "PPI3359291-2021"

EscRate.Value= ?

I dont know how to parse our the year and concatenate that.  Any help is appreciated - Thank you!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
try:
EscRate.value = IHSEscCode.value & "-" & year(EscalationBaseDate)
 
Upvote 0
Solution

Forum statistics

Threads
1,215,053
Messages
6,122,882
Members
449,097
Latest member
dbomb1414

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