Help separating data based on one column

davidmichael99

New Member
Joined
Nov 1, 2013
Messages
5
I am having issues separating data from one worksheet to multiple worksheets.
DATA: Entering product code onto a master sheet in column A with test results in column B, C, & D.

Example: Master sheet
ProductTest1Test2Test3
1540505558
2020192574
1540515455
2021854517

<TBODY>
</TBODY>


Result: After new product code is entered for that day onto master sheet I would like to press a button that would update the sheet and separate the data into multiple worksheets based on the product code. A sheet for 1540, 2040, and 2021.

Results: Sheet 1540
ProductTestTestTest
1540505558
1540515455

<TBODY>
</TBODY>


Is this possible to accomplish with excel functions, macro, or would I need VBA? Which would be the best way to approach this issue and where should I start? I have searched to net for examples but Im not really coming up with any results. Maybe Im just not searching for the right keywords. </SPAN>
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi, welcome to MrExcel.

Maybe Im just not searching for the right keywords.

I think so, yes, because there are plenty of topics on that. Or using Google:
https://sites.google.com/a/madrocke...celassistant/parse-functions/sheet1-to-sheets


Is this possible to accomplish with excel functions, macro, or would I need <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: rgb(0, 0, 0); cursor: help; color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">VBA</acronym>?

What is the difference between the last 2?
 
Upvote 0
davidmichael99,

Sample raw data in worksheet Master, before, and, after the macro:


Excel 2007
ABCD
1ProductTest1Test2Test3
21540505558
32020192574
41540515455
52021854517
6
Master


After the macro, three worksheets are created: 1540, 2020, and, 2021:


Excel 2007
ABCD
1ProductTest1Test2Test3
21540505558
31540515455
4
1540



Excel 2007
ABCD
1ProductTest1Test2Test3
22020192574
3
2020



Excel 2007
ABCD
1ProductTest1Test2Test3
22021854517
3
2021


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Option Explicit
Sub DistributeRows()
' hiker95, 11/01/2013
' http://www.mrexcel.com/forum/excel-questions/736582-help-separating-data-based-one-column.html
' The below macro code has been modified to reflect davidmichael99's thread request.
' Original macro code by Norie, 04/19/2008
' http://www.mrexcel.com/forum/excel-questions/315083-copy-row-content-another-sheet.html
Dim wsAll As Worksheet
Dim wsCrit As Worksheet
Dim wsNew As Worksheet
Dim LastRow As Long
Dim LastRowCrit As Long
Dim I As Long
Application.ScreenUpdating = False
Set wsAll = Worksheets("Master")
LastRow = wsAll.Range("A" & Rows.Count).End(xlUp).Row
Set wsCrit = Worksheets.Add
wsAll.Range("A1:A" & LastRow).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=wsCrit.Range("A1"), Unique:=True
LastRowCrit = wsCrit.Range("A" & Rows.Count).End(xlUp).Row
For I = 2 To LastRowCrit
  Set wsNew = Worksheets.Add
  wsNew.Name = wsCrit.Range("A2")
  wsAll.Rows("1:" & LastRow).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=wsCrit.Range("A1:A2"), _
    CopyToRange:=wsNew.Range("A1"), Unique:=False
  wsCrit.Rows(2).Delete
Next I
Application.DisplayAlerts = False
wsCrit.Delete
Application.DisplayAlerts = True
wsAll.Activate
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm

Then run the DistributeRows macro.
 
Upvote 0
davidmichael99,

You are very welcome. Glad I could help.

Thanks for the feedback.

And, come back anytime.
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,656
Members
449,091
Latest member
peppernaut

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