This is the formula I put in H4 of the original sheet and copy it down:
=SUMIF('[quickbooks file.xlsx]Sheet1'!$D:$D,$C4,'[quickbooks file.xlsx]Sheet1'!$F:$F)
Then you could enclose that with an if formula:
=IF(SUMIF('[quickbooks file.xlsx]Sheet1'!$D:$D,$C4,'[quickbooks file.xlsx]Sheet1'!$F:$F)=0,"",SUMIF('[quickbooks file.xlsx]Sheet1'!$D:$D,$C4,'[quickbooks file.xlsx]Sheet1'!$F:$F))
Note this require both workbooks to be opened.
In VBA you could do:
Sub CreateWorkbooksV2()
Dim timecodeSheet As Worksheet
Set timecodeSheet = Sheets("Sheet1")
Dim Bot As Integer ' May have to change this if the last row gets too big
Bot = timecodeSheet.Cells(Rows.Count, 1).End(xlUp).Row
'Add the formulas
Range(Cells(4, 8), Cells(Bot, 8)).FormulaR1C1 = "=IF(SUMIF('[quickbooks file.xlsx]Sheet1'!C4,RC3,'[quickbooks file.xlsx]Sheet1'!C6)=0,"""",SUMIF('[quickbooks file.xlsx]Sheet1'!C4,RC3,'[quickbooks file.xlsx]Sheet1'!C6))"
Dim newSheet As Worksheet
Sheets.Add After:=Sheets(Sheets.Count)
Set newSheet = ActiveSheet
timecodeSheet.Range("C:C").Copy Destination:=newSheet.Cells(1, 1) ' Done twice because of merged cells
timecodeSheet.Range("G:G").Copy Destination:=newSheet.Cells(1, 2)
timecodeSheet.Range("H:H").Copy Destination:=newSheet.Cells(1, 3) ' Done a third time for the new formula columns
For i = Bot To 4 Step -1 ' Start from the last row and go up
If Cells(i, 1) = "?" Or Cells(i, 1) = vbNullString Or UCase(Trim(Right(Cells(i, 1), 5))) = "TOTAL" Then Rows(i).Delete Shift:=xlUp ' If the first cell of row is ? or empty, delete the row
Next
End Sub
Bookmarks