AlphaNumeric Increment for a particular series not visible in Textbox if combobox value selected

NimishK

Well-known Member
Joined
Sep 4, 2015
Messages
684
In column B ther are Numbers from 2nd row to Last row. starting from 0001
in between in column B thereare numbers starting with "Z-" and these also respectively starting from 0001 but if i select in combobox "ABC"
I would like to auto increment the number with String "Z-0002 in the textbox when i select combox value as "ABC"

Code:
Private Sub UserForm_Initialize()
  With worksheets("Sheet1")
       .Columns("B").NumberFormat = "0000"
  End with
End Sub

Public Sub Auto_Increment_No()

Dim Var2 as Variant
Dim alpNum as String
If comboName.Text = "ABC" Then
          alpNum = "Z-" & Format(Var2 + 1, "0000")
          TextNos.Text = alpNum 
[B][COLOR=#ff0000]  '''''Here TextNos.Text showing Blank No increament Value at all[/COLOR][/B]
   Else
          TextNos.Text =  Format(Var2 + 1, "0000")
[B][COLOR=#ff0000]   ''''' Here it shows perfectly without alpNum[/COLOR][/B]
End Sub

Thanks
NimishK
 
Last edited:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Yes I got it, Thanks
Code:
Public Sub Auto_Increment_No()

Dim Var2 as Variant
If comboName.Text = "ABC" Then
          TextNos.Text = Left(Var2, 2) & Format(Val(Right(Var2, 4)) + 1, "0000") 
     Else
          TextNos.Text =  Format(Var2 + 1, "0000")
End if
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,217,429
Messages
6,136,575
Members
450,021
Latest member
Jlopez0320

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