WorksheetFunction.Sumifs with Absolute references...

FuNeS13

Board Regular
Joined
Oct 25, 2016
Messages
161
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. Mobile
  3. Web
I have this code:

VBA Code:
Dim Data_LR As Long
Dim Revision_LR As Long
Dim TheRange As Range
Dim Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7 As Range

Data_LR = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
Revision_LR = Sheets("Revision").Cells(Rows.Count, "B").End(xlUp).Row

Set Arg1 = ActiveWorkbook.Sheets("Data").Range("R2C22:R" & Data_LR & "C11")    ' Sum Range
Set Arg2 = ActiveWorkbook.Sheets("Data").Range("C2:C" & Data_LR)    ' Material # range
Set Arg3 = ActiveWorkbook.Sheets("Revision").Range("B8")            ' Material Ref Range
Set Arg4 = ActiveWorkbook.Sheets("Data").Range("F2:F" & Data_LR)    ' Year Range
Set Arg5 = ActiveWorkbook.Sheets("Revision").Range("G5")            ' Year
Set Arg6 = ActiveWorkbook.Sheets("Data").Range("H2:H" & Data_LR)    ' Week Range
Set Arg7 = ActiveWorkbook.Sheets("Revision").Range("G7")            'Week Number

Set TheRange = Sheets("Revision").Range("G8:N" & Revision_LR)

TheRange.Value = Application.WorksheetFunction.SumIfs(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)

That I want to make sure it works as this formula:

Excel Formula:
=SUMIFS(Data!$K$2:$K$112554, Data!$C$2:$C$112554, Revision!$B8, Data!$F$2:$F$112554, Revision!G$5, Data!$H$2:$H$112554, Revision!G$7)

So in my code I need to include the absolute references, but I'm not sure how to do that... Has anyone done this before? I personally don't want to use a loop but if there is no other option... Guess I'll settle for that....
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I have this code:

VBA Code:
Dim Data_LR As Long
Dim Revision_LR As Long
Dim TheRange As Range
Dim Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7 As Range

Data_LR = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
Revision_LR = Sheets("Revision").Cells(Rows.Count, "B").End(xlUp).Row

Set Arg1 = ActiveWorkbook.Sheets("Data").Range("R2C22:R" & Data_LR & "C11")    ' Sum Range
Set Arg2 = ActiveWorkbook.Sheets("Data").Range("C2:C" & Data_LR)    ' Material # range
Set Arg3 = ActiveWorkbook.Sheets("Revision").Range("B8")            ' Material Ref Range
Set Arg4 = ActiveWorkbook.Sheets("Data").Range("F2:F" & Data_LR)    ' Year Range
Set Arg5 = ActiveWorkbook.Sheets("Revision").Range("G5")            ' Year
Set Arg6 = ActiveWorkbook.Sheets("Data").Range("H2:H" & Data_LR)    ' Week Range
Set Arg7 = ActiveWorkbook.Sheets("Revision").Range("G7")            'Week Number

Set TheRange = Sheets("Revision").Range("G8:N" & Revision_LR)

TheRange.Value = Application.WorksheetFunction.SumIfs(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)

That I want to make sure it works as this formula:

Excel Formula:
=SUMIFS(Data!$K$2:$K$112554, Data!$C$2:$C$112554, Revision!$B8, Data!$F$2:$F$112554, Revision!G$5, Data!$H$2:$H$112554, Revision!G$7)

So in my code I need to include the absolute references, but I'm not sure how to do that... Has anyone done this before? I personally don't want to use a loop but if there is no other option... Guess I'll settle for that....
this first part should be Range("H2:H" & Data_LR) instead of Range("R2C22:R" & Data_LR & "C11"), I was trying something else lol
 
Upvote 0

Forum statistics

Threads
1,224,753
Messages
6,180,748
Members
452,996
Latest member
nelsonsix66

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