Variable Ranges

Paddy1979

Well-known Member
Joined
Sep 23, 2005
Messages
608
Hello All,

Can you help me please

I have the below macro which i plan to autofill down 100 rows, the trouble is it takes too long because i have set the SumProduct range of 65000 rows. The reason for that is the number of rows of data on the Jobs worksheet will change daily so i know this will cover them.

Can i name the range at the start of the macro without entering row numbers, ? ie Range is start of column I to end of data in column I??

Here is the code.

With ActiveSheet


With Range("F2")


.FormulaR1C1 = "=SUMPRODUCT(--(JOBS!R1C14:R65535C14=Sheet1!RC2),--(JOBS!R1C12:R65535C12=Sheet1!R1C))"
.Offset(0, 1).FormulaR1C1 = "=SUMPRODUCT(--(JOBS!R1C14:R65535C14=Sheet1!RC2),--(JOBS!R1C12:R65535C12=Sheet1!R1C))"
.Offset(0, 2).FormulaR1C1 = "=SUMPRODUCT(--(JOBS!R1C14:R65535C14=Sheet1!RC2),--(JOBS!R1C12:R65535C12=Sheet1!R1C))"
.Offset(0, 3).FormulaR1C1 = "=SUMPRODUCT(--(JOBS!R1C14:R65535C14=Sheet1!RC2),--(JOBS!R1C12:R65535C12=Sheet1!R1C))"
.Offset(0, 4).FormulaR1C1 = "=SUMPRODUCT(--(JOBS!R1C14:R65535C14=Sheet1!RC2),--(JOBS!R1C12:R65535C12=Sheet1!R1C))"
.Offset(0, 5).FormulaR1C1 = "=SUM(RC[-5]:RC[-1])"
.Offset(0, 6).FormulaR1C1 = "=IF(RC[-6]<1,0,RC[-6]/RC[-1])"
.Offset(0, 7).FormulaR1C1 = "=IF(RC[-7]<1,0,RC[-7]/(RC[-2]-RC[-3]))"

Man Thanks
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
add this:
Code:
LR = ActiveSheet.Range("A65536").End(xlUp).Row
then change your formulas (only did one as example)
Code:
.FormulaR1C1 = "=SUMPRODUCT(--(JOBS!R1C14:R" & LR & "C14=Sheet1!RC2),--(JOBS!R1C12:R" & LR & "C12=Sheet1!R1C))"
 
Upvote 0

Forum statistics

Threads
1,196,101
Messages
6,013,459
Members
441,767
Latest member
Craigh4444

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