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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
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
 

Forum statistics

Threads
1,147,621
Messages
5,742,193
Members
423,710
Latest member
Duarte85

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
Top