Data Validation: Global Search & Replace

Saighead

New Member
Joined
May 17, 2013
Messages
34
Hi,

I have the same data validation formula set for the range B:B on a couple of hundred worksheets. I need it replaced throughout the workbook by another formula. Is there a way to do it quickly with a macro or something? Changing the thing by hand will take half a day at least...

Thanks in advance.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Code:
Sub ChangeCF()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
    Set Rng = ws.Columns(2).SpecialCells(xlCellTypeAllFormatConditions)
    With Rng
        .FormatConditions.Delete
        .FormatConditions.Add Type:=xlExpression, Formula1:="=A1>30"
        With .FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 255
            .TintAndShade = 0
        End With
        .FormatConditions(1).StopIfTrue = False
    End With
Next
End Sub
 
Upvote 0
Thanks for the input, but it's not conditional formatting that I'm trying to change. It's about data validation (ribbon: Data > Data Validation > Settings). The formula I have now prevents identical entries but it's case-insensitive. I'm looking to do a global search in all worksheets and replace it with a case-sensitive one.
 
Upvote 0
sorry, here the code your validationchange

Code:
Sub ChangeDV
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
    Set Rng = ws.Columns(3).SpecialCells(xlCellTypeAllValidation)
    With Rng.Validation
        .Delete
        .Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=formula"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
Next
End sub
 
Last edited:
Upvote 0
You use now something like :=countif(c:c,c1)=1
 
Last edited:
Upvote 0
Maybe: =SUMPRODUCT(--ISERROR(FIND(B1,B:B)))=1048576-1
 
Last edited:
Upvote 0
It took just a few seconds to modify every worksheet in the file. Thanks a lot, I really appreciate your help, you've saved me a lot of hassle.
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top