WorksheetFunction.Sumifs with Absolute references...

FuNeS13

Board Regular
Joined
Oct 25, 2016
Messages
160
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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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,215,406
Messages
6,124,720
Members
449,184
Latest member
COrmerod

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