Hi,
I have a userform with two comboboxes which open other userforms depending on what value is selected in each combobox. The other userforms allow me to export data to an excel spreadsheet. I would like to prevent a user from opening up the other userforms if they have already used the values from both comboboxes. I would like to search the excel sheet in columns A & B and if values exist in A that match the combobox1's selection and Offset(0, 1)values in B match combobox2's selection then Exit Sub else open the other userforms.
Below is what I have tried so far with no luck.
<font face=Courier New><SPAN style="color:#00007F">Dim</SPAN> n, o <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br><SPAN style="color:#00007F">Dim</SPAN> q <SPAN style="color:#00007F">As</SPAN> Range<br>n = Home.HcmbboxWeekEnding.Text<br>o = Home.HcmbboxOperation.Text<br> <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> q <SPAN style="color:#00007F">In</SPAN> Range("a1:a200")<br> <SPAN style="color:#00007F">If</SPAN> q.Text = n And Cells(q.Row, 2).Text = o <SPAN style="color:#00007F">Then</SPAN><br> MsgBox ("Duplicate Entry")<br> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br> <SPAN style="color:#00007F">Else</SPAN><br> <br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br> <SPAN style="color:#00007F">Next</SPAN> q<br></FONT>
Thanks in advance for your help!
Will
I have a userform with two comboboxes which open other userforms depending on what value is selected in each combobox. The other userforms allow me to export data to an excel spreadsheet. I would like to prevent a user from opening up the other userforms if they have already used the values from both comboboxes. I would like to search the excel sheet in columns A & B and if values exist in A that match the combobox1's selection and Offset(0, 1)values in B match combobox2's selection then Exit Sub else open the other userforms.
Below is what I have tried so far with no luck.
<font face=Courier New><SPAN style="color:#00007F">Dim</SPAN> n, o <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br><SPAN style="color:#00007F">Dim</SPAN> q <SPAN style="color:#00007F">As</SPAN> Range<br>n = Home.HcmbboxWeekEnding.Text<br>o = Home.HcmbboxOperation.Text<br> <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> q <SPAN style="color:#00007F">In</SPAN> Range("a1:a200")<br> <SPAN style="color:#00007F">If</SPAN> q.Text = n And Cells(q.Row, 2).Text = o <SPAN style="color:#00007F">Then</SPAN><br> MsgBox ("Duplicate Entry")<br> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br> <SPAN style="color:#00007F">Else</SPAN><br> <br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br> <SPAN style="color:#00007F">Next</SPAN> q<br></FONT>
Thanks in advance for your help!

Will