How to make Countif with a Dynamic Range

Luchano

Board Regular
Joined
Jul 25, 2013
Messages
84
Hi all!

i'm using the formula below to find duplicates; however, i want to make the formula dynamic, so i don't have to change it everytime new data is added to sheet. Any help will be greatly appretiated.


=IF(COUNTIF(F2:F1774,F2)>1,"Remove",0)


Thank you!!!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Code:
[COLOR=#333333]=IF(COUNTIF(F:F,F2)>1,"Remove",0)[/COLOR]

Thank you, but that's not quite what i'm looking for. When you refer to an entire column it creates errors over large sums of data, and it assignes "Remove" to rows that shouldn't be removed.
 
Upvote 0
I've never had that issue before...unless you have data beneath your data set...

If you don't want to use the entire column, your only option for a dynamic formula is to input it using VBA.
 
Upvote 0
I've never had that issue before...unless you have data beneath your data set...

If you don't want to use the entire column, your only option for a dynamic formula is to input it using VBA.


Ok, so what would be the code?


Thanks for your quick response!!!
 
Upvote 0
Code:
Sub dynamicRange()

    Range(Cells(2, 7), Cells(Cells(Rows.Count, "F").End(xlUp).Row, 7)).FormulaR1C1 = _
        "=IF(COUNTIF(R2C6:R" & Cells(Rows.Count, "F").End(xlUp).Row & "C6, RC6) > 1, ""Remove"", 0)"


End Sub

Change the two instances of 7 for the column where the formula will go. 7 assumes column G.

8 = H
9 = I
10 = J

etc...
 
Upvote 0
Code:
Sub dynamicRange()

    Range(Cells(2, 7), Cells(Cells(Rows.Count, "F").End(xlUp).Row, 7)).FormulaR1C1 = _
        "=IF(COUNTIF(R2C6:R" & Cells(Rows.Count, "F").End(xlUp).Row & "C6, RC6) > 1, ""Remove"", 0)"


End Sub

Change the two instances of 7 for the column where the formula will go. 7 assumes column G.

8 = H
9 = I
10 = J

etc...

Thank a lot NeonRedSharpie!!!
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,217
Members
449,074
Latest member
cancansova

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