Prevent Duplicate export from Userform

willard8

New Member
Joined
Feb 5, 2009
Messages
34
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
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,216,109
Messages
6,128,875
Members
449,476
Latest member
pranjal9

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