Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:04:25+00:00 2026-06-15T14:04:25+00:00

My code is as follows If Cells(Target.Row, 2) = And (Cells(Target.Row, 3) = Or

  • 0

My code is as follows

If Cells(Target.Row, 2) = "" And (Cells(Target.Row, 3) = "" Or Cells(Target.Row, 3) = "") Then
    Sheets("MySheet").Activate
    Cells(Target.Row, 3).Activate
    ActiveCell.Validation.Delete
    If (Cells(Target.Row, 2) = "Type A") Then
        ActiveCell.Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=AvailableVersions"
    ElseIf (Cells(Target.Row, 2) = "Type B") Then
        ActiveCell.Validation.Delete
    Else
        ActiveCell.Validation.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertInformation, Formula1:="0", Formula2:="9999999"
    End If
End If

So the issue I am having comes whenever I reach ActiveCell.Validation.Add

Run Time Error '1004': Application-defined or object-defined error

Not a very helpful error, and also this occurs with both number and list validation type, so I am sure it is not an issue with the list itself which has workbook level scope anyway. It never occurs on ActiveCell.Validation.Delete which I find weird?

I have been all over google trying to find a solution, and most suggest that it is caused by running dynamic validation code from a button which hogs focus despite the Activate call, but I am running on sheet change event rather than on button press so I don’t think this is my issue – any ideas? I’ve wasted basically a whole day on this! 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:04:26+00:00Added an answer on June 15, 2026 at 2:04 pm

    Your code would be fine, if you weren’t running it from a worksheet event. For me the issue occurs when you try to select a new cell from within the event procedure. I rewrote what it looked like your code was trying to do without selecting a different cell.

    Try this:

    If Cells(Target.Row, 2) = "" And (Cells(Target.Row, 3) = "" Or Cells(Target.Row, 3) = "") Then
        With Sheets("MySheet")
            .Cells(Target.Row, 3).Validation.Delete
            If (.Cells(Target.Row, 2) = "Type A") Then
                .Cells(Target.Row, 3).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=AvailableVersions"
            ElseIf (.Cells(Target.Row, 2) = "Type B") Then
                .Cells(Target.Row, 3).Validation.Delete
            Else
                .Cells(Target.Row, 3).Validation.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertInformation, Formula1:="0", Formula2:="9999999"
            End If
        End With
    End If
    

    The other possible error would be if AvailableVersions is not a valid defined name for a list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got ASP generating the embed code on my page as follows: Table1.Rows(0).Cells(0).Text =
Currently, I have some code as follows template<typename Type> Type* getValue(std::string name, bool tryUseGetter
Why can't I do something like this in c# (pseudo code follows) Interface1 {
I'm using this plugin: http://www.jeremymartin.name/projects.php?project=kwicks And my code follows this example: http://www.jeremymartin.name/examples/kwicks.php?example=7 I'm using
I have code as follows: $(#item_select).change(function() { var params = $(#item_select option:selected).val(); $.post('/account/ar_form.php', {idata:
For some code as follows, opts, args = getopt.getopt(sys.argv[1:], c:, ... for o,v in
I have a piece of javascript code as follows: var data = { ...
I need to build some client side code which follows this use case: An
I'm setting the timeout value of an NSMutableURLRequest in code as follows: request.timeoutInterval =
I have 3 different jquery uses & put it into one code as follows:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.