Setting validation via VBA in excel fails when using variable

后端 未结 6 2025
野趣味
野趣味 2021-01-06 07:56

I am trying to set the data validation for a range of cells using VBA. I get a run-time error 1004 (so helpful) \"Application defined or object defined error\" with this cod

6条回答
  •  逝去的感伤
    2021-01-06 08:56

    Make sure that you are not passing into the Validation.Add a formula that is in row/column. For example "=R2C2:R3C3" caused me problems, as soon as I changed it to "B2:C3" it worked. Also the cells in the range MUST have values in them, or you will get application error.

提交回复
热议问题