macro to add up and put into the correct columns this weeks data

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
H ii everyone,
This is a bit complicated,, please help as i'm stuck
everyday I record the sales for that day and need a macro to add them up by product and move them to my yearly sales sheet.

So Sheet "Daily Sales"
Range D4 is the date

Range F15 to last row are the products I've sold today they might be more the one row for the same product
H15 down is the amount I've sold.

Now Sheet "Yearly Sales" is where I want to save this info,
Row 1 has dates
Row 10 down are my list of products.

So I need the sales in "daily sales" added up for each product and the data place in "Yearly Sales" under th right date and product name.

please help if you can

thanks
tony
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
How about
Code:
Sub SalesData()
   Dim Cl As Range, Dt As Range
   Dim Dws As Worksheet, Yws As Worksheet
   
   Set Dws = Sheets("Daily")
   Set Yws = Sheets("Yearly")
   Set Dt = Yws.Range("1:1").find(Dws.Range("D4"), , , xlWhole, , , , , False)
   With CreateObject("scripting.dictionary")
      For Each Cl In Dws.Range("F15", Dws.Range("F" & Rows.Count).End(xlUp))
         .Item(Cl.Value) = .Item(Cl.Value) + Cl.Offset(, 2).Value
      Next Cl
      For Each Cl In Yws.Range("A10", Yws.Range("A" & Rows.Count).End(xlUp))
         Cl.Offset(, Dt.Column - 1).Value = .Item(Cl.Value)
      Next Cl
   End With
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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