Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 563
- Office Version
- 365
- 2010
- Platform
- Windows
As of now, I have two textboxes on a userform. The second textbox(txtbxTRYD)just copies the value of the first textbox. Would it be possible to remove part of the word(s) of the first string. Here's an example:
S/A Aspirin 5mg 20ct
So using the above example in bold, I would only need the words Aspirin 5mg in the second textbox. I tried using both Replace and Split but I am not really familiar with Replace. The main problem is that the text will change depending on the different product names. The only thing I can come up with is using If...Then statements to achieve this. I just wanted to make sure that there wasn't an easier option. Below is that code. Thank You.
S/A Aspirin 5mg 20ct
So using the above example in bold, I would only need the words Aspirin 5mg in the second textbox. I tried using both Replace and Split but I am not really familiar with Replace. The main problem is that the text will change depending on the different product names. The only thing I can come up with is using If...Then statements to achieve this. I just wanted to make sure that there wasn't an easier option. Below is that code. Thank You.
VBA Code:
Private Sub txtbxPrdctName_Change()
Me.txtbxPrdctName = StrConv(Me.txtbxPrdctName.Value, vbProperCase)
Me.txtbxTYRD.Value = Me.txtbxPrdctName.Value
End Sub
Private Sub txtbxPrdctName_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(txtbxPrdctName.Value) > 2 Then
Me.txtbxPrdctName.Value = StrConv(Me.txtbxPrdctName.Value, vbProperCase)
MsgBox Me.txtbxTYRD.Value
End If
End Sub