How to copy the validation rules in vba?

Asked

Viewed 117 times

0

If Range("L9") > (Range("I9") + Range("J9")) Then
       Range("B8:O8").Interior.Color = RGB(255, 0, 0)

here i want to copy the validation rules if this happens

 End If

1 answer

1


Hello, If I understand correctly, you want to copy the data validation, but the data validation can not be copied, but you can add one like this:

Range("B4").Validation.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="0", Formula2:="10" 

This example only leaves numbers from 1 to 10 in the cell, you can use variables to copy the validation.

I hope I’ve helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.