VBA for Sumifs not working

Godders199

Active Member
Joined
Mar 2, 2017
Messages
313
Office Version
  1. 2013
Hello, I hope this is something obvious, but I can’t see it,effectively the basic formula works, but when I transpose that to vba, thecolumn just remains blank.
Effectively, I want the sum of the figures in column Q,where column G matches the name in the relevant line in the first line managerspreadsheet.

=SUMIFS(Hierarchy!Q:Q,Hierarchy!G:G,'First Line manager'!A2)
Code:
Dim lastrowcolumnd As Long
lastrowcolumnd = Range("a" &Rows.Count).End(xlUp).Row
For z = 2 To lastrowcolumnd
Sheets("first line Manager").Select
Cells(z, 3) = WorksheetFunction.SumIfs(ThisWorkbook.Sheets("Hierarchy").Range("q:q"),ThisWorkbook.Sheets("Hierarchy").Range("G:G"),ThisWorkbook.Sheets("First line manager"), Cells(z, 1))
Any help appreciated.
 
Last edited by a moderator:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
The last part should be:

Code:
ThisWorkbook.Sheets("First line manager").Cells(z, 1)

and not:

Code:
ThisWorkbook.Sheets("First line manager"), Cells(z, 1)
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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