Data Validation

markoakes

Active Member
Joined
Jan 5, 2004
Messages
325
I’m not sure of the best way to do this. I have a customer data sheet that lists all customers. In column “B” is their Charge Status, either “Cash” or “Charge”. I want to stop the Charge Status from being changed from Cash to Charge if the Balance in Column “C” is greater then 5000.00 or the Account Status in column “D” is less then 2. Any help would be greatly appreciated.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

onlyadrafter

Well-known Member
Joined
Aug 19, 2003
Messages
5,703
Platform
  1. Windows
Hello,

Is this suitable?

It needs to go into the relevant sheet code window

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 And UCase(Target.Value) = "CHARGE" Then
    If Range("C" & Target.Row).Value > 5000 Or Range("D" & Target.Row).Value < 2 Then
        MY_MSG = MsgBox("CANNOT CHANGE", vbOKOnly, "ERROR")
        Application.Undo
    End If
End If
End Sub
 

markoakes

Active Member
Joined
Jan 5, 2004
Messages
325
The above code works great if "Charge" is being typed in the cell. Is there a way to make it work if Copy,Paste or Drag&Drop is used?
 

Forum statistics

Threads
1,136,864
Messages
5,678,214
Members
419,751
Latest member
TryingtoLearnVBA

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