complicated autonumber in textbox based on others multiple textboxes

MKLAQ

Active Member
Joined
Jan 30, 2021
Messages
396
Office Version
  1. 2016
Platform
  1. Windows
hi
I have multiple text boxes 2,3,4 contains digits and letters and sometimes symbols . the problem is not always same the digits of numbers and letters and symbols about textbox GOOD the first two letters always contain one space but how many letters somtimes three or four . so what I want as in picture 1 take the first letters in goods BM, and take the first letter in made T and take the whole manafac F580 and take the whole number in goods with ignore letters or symbols contains it .
actually I know this is very complicated and I no know how explain clearly so if that's not clear please inform me what you want to know about detailes
see some cases .

1.PNG




2.PNG





3.PNG




4.PNG
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi, @MKLAQ
I made an example on sheet not textbox, so you need to adjust it.
VBA Code:
Private Sub CommandButton1_Click()
Dim a As String, a1 As String, b As String, c As String, n As String
    a = Range("B2").Value
    a1 = Split(a)(0)

For i = 1 To Len(a)
    If Mid(a, i, 1) Like "#" Then n = n & Mid(a, i, 1)
Next

    b = Range("C2").Value
    c = Left(Range("D2").Value, 1)
    Range("A2") = a1 & c & b & n
End Sub

MKLAQ.xlsm
ABCD
1CODEGOODMANFACMADE
2BMTF5801112315BM 111/23R15F580TUR
Sheet1
 
Upvote 0
thanks . actually I would that by textboxes when writing in textbox2,3,4 should show the number in textbox1 and when delete one of them should clear in textbox1 . if there is way to do that will be great
 
Upvote 0
I can but amend the to do that. But first I need you to try the code to see if it works.
 
Upvote 0
OK . I tested for some cases and it works . I hope there is no problem about others cases
 
Upvote 0
Ok try this:

TextBox1 is CODE
TextBox2 is GOOD
TextBox3 is MANFAC
TextBox4 is MADE


VBA Code:
Sub toFill(a As String, b As String, c As String)
Dim n As String
    a1 = Split(a)(0)

For i = 1 To Len(a)
    If Mid(a, i, 1) Like "#" Then n = n & Mid(a, i, 1)
Next

    c = Left(c, 1)
    TextBox1 = a1 & c & b & n

End Sub

Private Sub TextBox2_Change()

    If TextBox2.Value = "" Or TextBox3.Value = "" Or TextBox4.Value = "" Then
        TextBox1.Value = ""
    Else
         Call toFill(TextBox2.Value, TextBox3.Value, TextBox4.Value)
    End If

End Sub
Private Sub TextBox3_Change()

    If TextBox2.Value = "" Or TextBox3.Value = "" Or TextBox4.Value = "" Then
        TextBox1.Value = ""
    Else
        Call toFill(TextBox2.Value, TextBox3.Value, TextBox4.Value)
    End If

End Sub
Private Sub TextBox4_Change()

    If TextBox2.Value = "" Or TextBox3.Value = "" Or TextBox4.Value = "" Then
        TextBox1.Value = ""
    Else
        Call toFill(TextBox2.Value, TextBox3.Value, TextBox4.Value)
    End If

End Sub

the file:
 
Upvote 0
Solution
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0
sorry I came back but I try making the code implement for multiple textboxes for instance when I write another textbox 6,7,8 then should show the number in textbox5 and if I write in textboxes 10,11,12 then should show the number in textbox 9 and so on I think coping the function and change its name to implement to for each four textboxes , then the userform will continue much more codes . if there is way do that by loop or array to make the code short . it will be a great .

thanks again
 
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,309
Members
449,080
Latest member
jmsotelo

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