Stop Restricted Customers from being Booked.

Sir Boffalot

New Member
Joined
Dec 8, 2004
Messages
10
Hello!

OK. This is a bit difficult to explain, but here goes anyway...
On my excel workbook based on an aeroplane when you try to book a customer to a seat by clicking a command button, a VBA userform opens asking you to choose a customer to book the seat to, all the customers are in a combo box linked to an excel worksheet called "Customers"... Anyway in "Customers" across from the customer's name is a column called "Restricted?" if this equals Y then I want a msgbox to pop up saying the reason which is in another column on the same row and then the customer to be refused access to the seat.

Can anyone help? :rolleyes:

Sorry about the confusing explanation. :oops:

Thank You. :)
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi there,

Sounds like you want a worksheet change event. What cell value will change (most precedent cell) to give you your 'flag logic'? I'll assume for a moment that it is column A (Restricted), and the reason is in column C and will be in the same row.

..

<font face=Tahoma New><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN>

<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)
    <SPAN style="color:#007F00">'assuming headers in row 1</SPAN>
    <SPAN style="color:#00007F">If</SPAN> Target.Row < 2 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
    
    <SPAN style="color:#00007F">Dim</SPAN> mRow <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
    mRow = Target.Row
    
    <SPAN style="color:#00007F">If</SPAN> UCase(Range("A" & mRow).Value) = "Y" <SPAN style="color:#00007F">Then</SPAN>
        MsgBox "Seat is Restricted." & vbNewLine & vbNewLine & _
            "  Reason:" & vbNewLine & "  " & _
            Range("C" & mRow).Value, vbInformation, "Restricted!"
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
    
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>


To install code, right click sheet tab --> View Code, paste on right.


HTH
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,628
Members
449,241
Latest member
NoniJ

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