how increment number int textboxes based on filling comboboxes on userfrom

Abdo

Board Regular
Joined
May 16, 2022
Messages
183
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hi

I want way to increment number for column 1 on userform under lable(ITEM) based on filling comboboxes for column 2 under lable(BATCH)

the textboxes in column ITEM(textbox1:textbox12) but comboboxes for column 2 under lable(BATCH) their numbers is not consecutively

will be increment up to numbers 4 when move next row (combobox1,5,9,13.....)

first
11111.PNG






result
22222.PNG

any suggestion guys?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try this formula in the ITEM column (assuming that the instance is in cell A2)

Excel Formula:
=IF(B2="", "", ROW()-1)
 
Upvote 0
If you are looking for a VBA solution, try this.

This will work as long as there is no break between your BATCH entries - It auto refreshes and clears the cell if data is erased so I think it might prove to be useful

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Update 20140722
Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Set WorkRng = Intersect(Application.ActiveSheet.Range("B:B"), Target)
xOffsetColumn = -1
If Not WorkRng Is Nothing Then
    Application.EnableEvents = False
    For Each Rng In WorkRng
        If Not VBA.IsEmpty(Rng.Value) Then
            Rng.Offset(0, xOffsetColumn).Value = Rng.Count() + Rng.Offset(-1, xOffsetColumn).Value
        Else
            Rng.Offset(0, xOffsetColumn).ClearContents
        End If
    Next
    Application.EnableEvents = True
End If
End Sub

If you are looking for a solution which allows for breaks in data entries please specify
 
Upvote 0
thanks for your effort , but you misunderstood my question , your code deals with the sheet . in my case should deal with the userform directly without depends on sheet .
 
Upvote 0

Forum statistics

Threads
1,215,032
Messages
6,122,772
Members
449,095
Latest member
m_smith_solihull

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