Formula in VBA: Can't make it myself. Please help.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, I have this formula. How can i write this in VBA to pick the range till last row taking col B as primary key. For now it is picking up till 79 row.

'=SUM(INT($J$3/$J$4*G3),IF(RANK(I3,$I$3:$I$79,0)+COUNTIF(I$3:I3,I3)-1<=($J$3-SUMPRODUCT(INT($J$3/$J$4*$G$3:$G$79))),1,0))

Thanks in Adv.
Pedie:)
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi Pedie. Try like this

Code:
LR = Range("B" & Rows.Count).End(xlUp).Row
ActiveCell.Formula = "=SUM(INT($J$3/$J$4*G3),IF(RANK(I3,$I$3:$I$" & LR & ",0)+COUNTIF(I$3:I3,I3)-1<=($J$3-SUMPRODUCT(INT($J$3/$J$4*$G$3:$G$" & LR & "))),1,0))"
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,521
Members
452,923
Latest member
JackiG

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