Data Validation using VBA and Excel function

ManUBlueJay

Active Member
Joined
Aug 30, 2012
Messages
320
Office Version
  1. 365
Platform
  1. Windows
I have an entry Form where one cell will either have a drop down list or free flow with a duplicate check
Drop Down list is named as Range1 I use this VBA code and it works as intended
VBA Code:
With Range("F1").Validation
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=Range1l"
        .IgnoreBlank = True
        .InCellDropdown = True
    End With

F1 is also needs to be freeform when another criteria is met.
I would like a DupCheck.
When I use this formula in F1 as a custom data validation it works =COUNTIF(DS_ProjectNumsRange,F1)<1
When I name this Formula as Range2 and use =Range2 in F1 as a custom validation it no longer functions.
Question 1 is why?

Question 2 if Question 1 is a bug in Excel how do I enter the formula =COUNTIF(DS_ProjectNumsRange,F1)<1 in F1 using VBA.

Prefered solution would be using the formula
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,223,880
Messages
6,175,154
Members
452,615
Latest member
bogeys2birdies

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