Help in assigning formula to range

Haree

Board Regular
Joined
Sep 22, 2019
Messages
146
Office Version
  1. 2016
Hello, Kindly excuse me if this question is very elementary as I am new to VBA and am learning.

I have a defined range

VBA Code:
dessum = wsd.Range("L2:L" & lastrowa)

I want to update the following formula in the entire range

=SUMIFS($F$2:$F$4,$C$2:$C$4,[@Names])-SUMIFS($E$2:$E$4,$C$2:$C$4,[@Names])

Any help would be greatly appreciated
Thank You
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You need Set when assigning a range to a variable, or you just get an array of values, so:

VBA Code:
Set dessum = wsd.Range("L2:L" & lastrowa)
dessum.formula = "=SUMIFS($F$2:$F$4,$C$2:$C$4,[@Names])-SUMIFS($E$2:$E$4,$C$2:$C$4,[@Names])"

I'm assuming that the range is part of a table, based on your formula, in which case you should really refer to it as such.
 
Last edited:
Upvote 0
Solution
@RoryA Thank you so much sir. It worked perfectly fine. Thanks for helping me out with set as well.
A small query, can I pull "lastrowa" inside my sumif formula. For Instance

=sumifs(("F2:F" & lastrowa),("C2:C" & lastrowa),[@Names])

If i can do how am i supposed to use the $ along with it
Thank you once again.
 
Upvote 0
You can but if your formula is in a table and referring to columns in that table, you might as well use table references.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,241
Members
449,075
Latest member
staticfluids

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