Sumproduct with dynamic range

Xcels

New Member
Joined
Dec 15, 2022
Messages
11
Office Version
  1. 2016
Platform
  1. Windows
'Duplicate Check Column V
Range("V1").Select
ActiveCell.FormulaR1C1 = "Duplicate Check"
Range("V2").Select
ActiveCell.Formula2R1C1 = _
"=SUMPRODUCT((RC15<=R2C16.End(x1down))*(RC16>=R2C15.End(x1down))*(RC7=R2C7.End(x1down))"
Range("V2").Select
Selection.AutoFill Destination:=Range("V2.End(x1down)")

The formula is as follows:
=SUMPRODUCT(($O2<=$P$2:$P$10000)*($P2>=$O$2:$O$10000)*($G2=$G$2:$G$10000))

I put a range up to 10000 rows but in theory the number of rows differ with each worksheet. So, it would be ideal to capture till last row.

Any help would be much appreciated.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi & welcome to MrExcel.
How about
VBA Code:
   Dim Lr As Long
   'Duplicate Check Column V
   Range("V1").Value = "Duplicate Check"
   Lr = Range("O" & Rows.Count).End(xlUp).Row
   Range("V2:V" & Lr).Formula2R1C1 = _
      "=SUMPRODUCT((RC15<=R2C16:r" & Lr & "c16)*(RC16>=R2C15:r" & Lr & "c15)*(RC7=R2C7:r" & Lr & "c7))"
 
Upvote 0
Solution
Hi,

Thank you so much. It works exactly as I wanted. I appreciate the help!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

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