0

I've looked online for an hour and can't find any solution that has worked for me. I have a range of cells which I want to apply data validation to each cell in that range based on another range. I am not sure if I need a For Each loop or if I can just assign the validation to the whole list at one time. Here is what I have so far:

With Range(rngMonthStart, rngMonthEnd)
    With .Validation
         .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:= ("='Settings'!" & totalrange.Address)
    End With
End With

When it gets to the .Add line I get an Application Defined Error. Any help is super appreciated

3
  • Try removing the () surrounding the formula Commented Feb 7, 2017 at 23:19
  • @BruceWayne I tried both methods, same error :/ Commented Feb 7, 2017 at 23:20
  • delete the previous data validation and totalrange might have to be only one column or row stackoverflow.com/questions/22956604/… Commented Feb 7, 2017 at 23:25

2 Answers 2

4

You seem to be overwriting the validation. If it already exists, overwriting leads to runtime error. Try:

With .Validation
    .Delete  
    .Add ...
Sign up to request clarification or add additional context in comments.

1 Comment

Ahhhh perfect. I didn't delete. Thank you.
0

In case you have done the .Delete, and it still fail at .Add with "Application Defined Error". Please check if the worksheet is protected or not. It should run fine once the worksheet is unprotected.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.