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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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
thanks Rory , I had just noticed and was coming back to say i had got it to work.
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,048
Members
448,543
Latest member
MartinLarkin

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