VBA Code to see if criteria in a user form matches to a row in a table

dbkimber

New Member
Joined
Mar 23, 2016
Messages
14
I'm trying to use a form to match criteria in entered in a user form to a row in a table. If box1 value is found in the table and the value in box2 if found in the cell to the right of the value in box1 and the value in box3 is found in the same row as the first two boxes values, then I want to load the value in box4 to specific place in a sheet. if something doesn't match i want to have a message box pop up saying something doesn't match.
 
working of a work computer that blocks any downloads the table i pasted is the the table im working off of. i can paste the code as ive adjusted it in here along with
a screen shot of the user form im building

VBA Code:
Private Sub CommandButton1_Click()
  Dim r As Range, f As Range, exists As Boolean, cell As String
 
  Set r = Range("Master[[#All],[Cert 1]:[Cert 16]]")
  Set f = r.find(cmbcrt.Value, , xlValues, xlWhole)
  If Not f Is Nothing Then
    cell = f.Address
    Do
      If Range("F" & f.Row) = cmbsign And Range("G" & f.Row) = codbx Then
        exists = True
        'it would perform a task
        Exit Do
      End If
      Set f = r.FindNext(f)
    Loop While Not f Is Nothing And f.Address <> cell
  End If
 
  If exists = False Then MsgBox "Your code does not match or you don't hold and active cert for that book. Please check the information entered."
End Sub

Signer would be cmbsign  (been referring to as box1)
Authorization code is (codbx been referring to as box2)
Cert Book is cmbcrt (been referring to as box3)
[ATTACH type="full"]8093[/ATTACH]
 

Attachments

  • 1583187102013.png
    1583187102013.png
    13.4 KB · Views: 8
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Signer would be cmbsign (been referring to as box1)
Authorization code is (codbx been referring to as box2)
Cert Book is cmbcrt (been referring to as box3)


the above isn't supposed to be in the code part of the reply
 
Upvote 0
The macro works for me.

You can put a sample of your data where you can see the names of the columns. Use xl2bb tool.

Please provide a sample of your data with which you are testing.
 
Upvote 0

Forum statistics

Threads
1,216,091
Messages
6,128,775
Members
449,468
Latest member
AGreen17

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