How to copy the validation rules in vba?

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
    
asked by anonymous 04.07.2017 / 15:59

1 answer

1

Hello, If I understood correctly, you want to copy the data validation, however the data validation can not be copied, but you can add an equal 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 have helped.

    
05.07.2017 / 13:09