restrict value in textboxes on userform and pop up message based on matching column

abdo meghari

Active Member
Joined
Aug 3, 2021
Messages
465
Office Version
  1. 2019
hello
I have amany multiple comboboxes linked with COLUMN B,C,D,E and textboxes link with column F about the QTY for textboxes start from 6 to 10 is for the ITEM start from 1 to 5

so what I want when select combobox category should automatically fill the others , and I write values in textboxes (QTY) manually if less than or equal what are existed in sheet1 in COL F and press command button then should copy to sheet2 from row4 and if they are bigger than what are existed in sheet1 in col F then should show message contain detailes the QTY for the items and doesn't copy to sheet2 like this

"this is bigger than what available please choose less"

item QTY

1 10

2 30
attached some pictures
step1
1.PNG



step2 should fill automatically
2.PNG





step3 write values manually in textboxes(QTY)


3.PNG



should compare with COL B,C,D,E,F and pop up message if the values are bigger and not copy to sheet2 in this case
and if less or equal then should copy to sheet2
thanks in advance
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
this is the current code for mr Akuini .I got from this forum
when select the items from combobox (Category) it will populate the others combobox this step is Ok, but what I search for it when I fill value in textbox (QTY) manually should match with QTY with COL F . and if the textbox (QTY) > QTY in COL(F) then should pop up message" the QTY is bigger . available QTY is .... " and clear the textbox and if less or equal then should copy data from user from to sheet2
VBA Code:
Private Sub ComboBox5_Change()

Dim c As Range
With Sheets("Sheet1")
  
    Set c = .Range("B:B").Find(What:=ComboBox5.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    If Not c Is Nothing Then
        ComboBox6.Value = c.Offset(, 1).Value
        ComboBox7.Value = c.Offset(, 2).Value
        ComboBox8.Value = c.Offset(, 3).Value
      
        
    End If
End With
End Sub



Private Sub ComboBox9_Change()



Dim c As Range
With Sheets("Sheet1")
  
    Set c = .Range("B:B").Find(What:=ComboBox9.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    If Not c Is Nothing Then
        ComboBox10.Value = c.Offset(, 1).Value
        ComboBox11.Value = c.Offset(, 2).Value
        ComboBox12.Value = c.Offset(, 3).Value
      
      
    End If
End With
End Sub
Private Sub TextBox1_Change()
    TextBox1 = Format(TextBox1, "#,##0.00")

End Sub

Private Sub TextBox2_Change()
TextBox2 = Format(TextBox2, "#,##0.00")
End Sub

Private Sub TextBox3_Change()
TextBox3 = Format(TextBox3, "#,##0.00")
End Sub

Private Sub TextBox4_Change()
TextBox4 = Format(TextBox4, "#,##0.00")
End Sub

Private Sub TextBox5_Change()
TextBox5 = Format(TextBox5, "#,##0.00")
End Sub

Private Sub TextBox6_Change()
TextBox6 = Format(TextBox6, "#,##0.00")
End Sub

Private Sub TextBox7_Change()
TextBox7 = Format(TextBox7, "#,##0.00")
End Sub

Private Sub TextBoxPrice_Change()
TextBoxPrice = Format(TextBoxPrice, "#,##0.00")
End Sub

Private Sub TextBoxTotal_Change()
TextBoxTotal = Format(TextBoxTotal, "#,##0.00")

End Sub

Private Sub UserForm_Initialize()
With Sheets("Sheet1")
    With .Range("B2", .Cells(.Rows.Count, "B").End(xlUp))
        For i = 1 To 4
            Me.Controls("ComboBox" & i).List = .Offset(, i - 1).Value
            Me.Controls("ComboBox" & i + 4).List = .Offset(, i - 1).Value
            Me.Controls("ComboBox" & i + 8).List = .Offset(, i - 1).Value
        Next
    End With
End With

End Sub


Private Sub ComboBox1_Change()
Dim c As Range
With Sheets("Sheet1")
  
    Set c = .Range("B:B").Find(What:=ComboBox1.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    If Not c Is Nothing Then
        ComboBox2.Value = c.Offset(, 1).Value
        ComboBox3.Value = c.Offset(, 2).Value
        ComboBox4.Value = c.Offset(, 3).Value
      
        
    End If
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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