How to get rid of error code/window popping up

JasonRafton

New Member
Joined
Feb 1, 2023
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Below is a code I have on my XL sheet.
I need to be able to put a NAME, that is not on any of the LISTS, in column 8 from time to time.
At the moment an ERROR CODE comes up and doesn't allow me.
Normally I would go into the data validation and uncheck the box. But that doesn't seem to work because of the CODE.
How can I get around this?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 4 Then Exit Sub
If Target.Value = "SUB" Then
' Adjust with your Own choices in Formula1:
With Target.Offset(0, 8).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="KRUEGER,ROYANS,T/SALES,VAWDREY,VOLVO,BDS,HAMMAR"
End With
ElseIf Target.Value = "WIP" Then
With Target.Offset(0, 8).Validation
' Adjust with your Own choices in Formula1:
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="ALEX B,JYE P,LUKE K,BDS-ETHAN,BDS LACHLAN,OP-MATT,STT-TRAVIS,STT-ALEX,STT-ALF,STT-NICK S,STT-TIM,TSS-GERRY,TSS-TRENTE"
End With
ElseIf Target.Value = "OS" Then
With Target.Offset(0, 8).Validation
' Adjust with your Own choices in Formula1:
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="ALEX B,JYE P,LUKE K,BDS-ETHAN,BDS LACHLAN,OP-MATT,STT-TRAVIS,STT-ALEX,STT-ALF,STT-NICK S,STT-TIM,TSS-GERRY,TSS-TRENTE"
End With
End If
End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
In your macro change in the three lines of code the parameter:
AlertStyle:=xlValidAlertStop to (whichever you prefer):
AlertStyle:=xlValidAlertInformation or:
AlertStyle:=xlValidAlertWarning
 
Upvote 0
Hi,

You can use : AlertStyle:=xlValidAlertInformation
 
Upvote 0
Add:
.ShowInput = False
or:
.ShowError = False
 
Last edited:
Upvote 0
You can insert the ShowError just after the three lines with: .Add Type:=xlValidateList, ...
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,849
Members
449,051
Latest member
excelquestion515

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