Sumif across multiple tabs

colinheslop1984

Board Regular
Joined
Oct 14, 2016
Messages
129
Office Version
  1. 2016
I want to create a working document which will compare sales data LFL

Multiple sets of data needs to be imported on a weekly basis on separate tabs, i.e WK01, WK02, WK01LY, WK02LY, etc. The layout of these sheets will always be identical.

Rather than having to repeat formula's 52 times on separate sheets, I would like a master sheet that will just let me choose which 2 tabs I want to compare data. Purely for simplicity, the data sheets will be laid out the same as below, minus the 'VS LY' column, its this column I would like to calculate. I'm thinking I would use data validation to insert a list of the tab names (in cell G1) then do some form of sumif formula? but not sure where I would go from there. Help please.

CATEGORYUNITSVS LYSALES
DENIMB2C2D2
DRESSESB3C3D3
ETCB4C4D4

<tbody>
</tbody>
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi,

You really shared a minimum on data to go on so i can't do much more than give you some direction. Basically your OP contains 2 parts:
1. create a list of sheets used in the workbook and apply Data Validation to them so you can use it as a selecting field for the tabs to get the data from;
2. how to use the sheetname in the SUMIF function to collect the data from the sheet choosen;

For purpose of simplicity i'm assuming your comparing data on a weekly basis.

see if this helps:

Book1
ABCDEFG
1CATEGORYUNITSVS LYSALESVS LYWK01
2DENIM4593353911482588475
3DRESSES6002218815005054700
4ETC97998279244975206975
recap
Cell Formulas
RangeFormula
B2=SUMIF(INDIRECT("'"&$G$1&"'!A:A"),recap!A2,INDIRECT("'"&$G$1&"'!b:b"))
C2=B2-SUMIF(INDIRECT("'"&$G$1&"LY'!A:A"),recap!A2,INDIRECT("'"&$G$1&"LY'!b:b"))
D2=SUMIF(INDIRECT("'"&$G$1&"'!A:A"),recap!A2,INDIRECT("'"&$G$1&"'!c:c"))
E2=D2-SUMIF(INDIRECT("'"&$G$1&"LY'!A:A"),recap!A2,INDIRECT("'"&$G$1&"LY'!c:c"))
 
Upvote 0
Insert a sheet and name it as Summary and try the following macro codes
Sub yyy()
Cells(1, 26) = "sheetnames"
For a = 1 To Sheets.Count
If Sheets(a).Name <> "summary" Then
Cells(a, 26) = Sheets(a).Name
End If
Next a


x = Sheets("summary").Cells(Rows.Count, 26).End(xlUp).Row
Range("Z2:Z" & x).Select
ActiveWorkbook.Names.Add Name:="weeks", RefersToR1C1:= _
"=summary!R2C26:R" & x & "C26"
Range("G1:G2").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=weeks"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
MsgBox "complete"
End Sub
on running, it lists the sheet names in column Z and creates a drop down in G1 and G2. You may choose the sheets to be compared and write sumif formulae suitably.
Ravi shankar
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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