Split Data based on Column Headings with Two Criteria Month Column and Store Column

AVALADEZ75

New Member
Joined
Apr 12, 2013
Messages
2
Hello,

I am trying to split data that has a month column and store columns. I want to be able to split the data into different worksheets based on store columns and have it show the totals by months.

MonthsStore 1Store 2
12 $ 1,000,000.00 $ 200,000.00
4 $ 1,000,000.00 $ 200,000.00
1 $ 1,000,000.00 $ 200,000.00
2 $ 1,000,000.00 $ 200,000.00
8 $ 1,000,000.00 $ 200,000.00
11 $ 1,000,000.00 $ 200,000.00
6 $ 1,000,000.00 $ 200,000.00
10 $ 1,000,000.00 $ 200,000.00
3 $ 1,000,000.00 $ 200,000.00
7 $ 1,000,000.00 $ 200,000.00
9 $ 1,000,000.00 $ 200,000.00
5 $ 1,000,000.00 $ 200,000.00

<colgroup><col style="width:48pt" width="64"> <col style="mso-width-source:userset;mso-width-alt:4315;width:89pt" width="118"> <col style="mso-width-source:userset;mso-width-alt:3218;width:66pt" width="88"> </colgroup><tbody>
</tbody>



Master Sheet

below I would like the sheets to be named after each column "Store #" and have
MonthsStore 1
12 $ 1,000,000.00
4 $ 1,000,000.00
1 $ 1,000,000.00
2 $ 1,000,000.00
8 $ 1,000,000.00
11 $ 1,000,000.00
6 $ 1,000,000.00
10 $ 1,000,000.00
3 $ 1,000,000.00
7 $ 1,000,000.00
9 $ 1,000,000.00
5 $ 1,000,000.00

<colgroup><col><col></colgroup><tbody>
</tbody>




Let me know if you can help.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
The master sheet will remain as is. I am hoping that a macro can take the month column and each individual store column and seperate them into their own sheets. That way the excel work book will have the Master, Store1, Store 2, store 3, etc and in the store worksheets it will show Column A Month, Column B Store 1 and the data.
 
Upvote 0
I have assumed that your data start in Cell A1:


Excel 2010
ABC
1MonthsStore 1Store 2
212$ 1,000,000.00$ 200,000.00
34$ 1,000,000.00$ 200,000.00
41$ 1,000,000.00$ 200,000.00
52$ 1,000,000.00$ 200,000.00
68$ 1,000,000.00$ 200,000.00
711$ 1,000,000.00$ 200,000.00
86$ 1,000,000.00$ 200,000.00
910$ 1,000,000.00$ 200,000.00
103$ 1,000,000.00$ 200,000.00
117$ 1,000,000.00$ 200,000.00
129$ 1,000,000.00$ 200,000.00
135$ 1,000,000.00$ 200,000.00
Sheet1


This will do as you asked:

Code:
Sub Split_Stores()
Dim i As Long, j As Long
Dim LastRow As Long, LastCol As Long
Dim ws1 As Worksheet, ws2 As Worksheet


Set ws1 = ActiveSheet


LastRow = ws1.Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Row
LastCol = ws1.Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Column


For i = 2 To LastCol
Set ws2 = Sheets.Add
ws2.Move After:=Sheets(Sheets.Count)
ws2.Name = ws1.Cells(1, i)
    For j = 1 To LastRow
        ws2.Cells(j, 1) = ws1.Cells(j, 1): ws2.Cells(j, 2) = ws1.Cells(j, i)
    Next j
Next i


End Sub
 
Upvote 0

Forum statistics

Threads
1,203,186
Messages
6,053,984
Members
444,696
Latest member
VASUCH

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