Copy certain row to new sheet

miracleyy

New Member
Joined
Dec 17, 2013
Messages
26
Dear all,

i would like to copy each new order start from row "PH Order No:" to "0" to new sheet.
for below example, i would like to separate 4 order to 4 sheet.

Please help!!!


21kkobd.jpg
 
miracleyy,

Thanks for the workbook.

In the future when asking for help, please display before, and, screenshots, or, attach a workbook as you did on your last reply #20.

This way we can normally find a solution on the first go.

Be back later with an update.
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
miracleyy,

Thanks for the workbook.

Sample raw data for one order number in worksheet Sheet1:


Excel 2007
ABCDEFGHIJ
1Pick No:10056915Order No:10048992Customer Name:P-ASLCKSTORE (Location A )
2Product CodePicking QtyTotal PCEno.Product nameStorCondCSPKPCEInvType
310011002SANKO 24pcs1AmbientNormal12X1300404-HLC
410013522URASHIMA 6g2AmbientNormal2X30110404-HLC
510213002SUNTORY 420ml3AmbientNormal24X12005F02-01-070
661036.700.213000174Total:
Sheet1


After the macro in two of the new worksheets:


Excel 2007
ABCDEFGHIJ
1Pick No:10056915Order No:10048992Customer Name:P-ASLCKSTORE (Location A )
2Product CodePicking QtyTotal PCEno.Product nameStorCondCSPKPCEInvType
310011002SANKO 24pcs1AmbientNormal12X1300404-HLC
410013522URASHIMA 6g2AmbientNormal2X30110404-HLC
510213002SUNTORY 420ml3AmbientNormal24X12005F02-01-070
661036.700.213000174Total:
7
10048992



Excel 2007
ABCDEFGHIJ
1Pick No:10048726Order No:10048996Customer Name:P-ASTKOSTORE (Location E )
2Product CodePicking QtyTotal PCEno.Product nameStorCondInvTypePackingLocationLot Number
310044422NABISCO 13PCSx3PK1AmbientNormal8X6100404-HLC
410555552ITOU 90g2AmbientNormal20X1200404-HLC
510441002EBARA 245ml3AmbientNormal20X1200404-HLC
610013522URASHIMA8PCS4AmbientNormal2X12500404-HLC
710213002MEIJI 9PCS5AmbientNormal30X1100404-HLC
810011002MEIJI 9PCS6AmbientNormal10X1100512-HLC
910013522ITOU 80g7AmbientNormal3X102005A01-02-050
1010044422NABISCO 13PCSx3PK8AmbientNormal2X102005A01-02-060
1110555552ITOU 90g9AmbientNormal12X15005A01-02-060
1210441002EBARA 245ml10AmbientNormal12X14005A01-02-060
1310013522URASHIMA8PCS11AmbientNormal2X150105A01-03-030
1410213002NABISCO 44gx3PK12AmbientNormal2X102005A02-05-030
1510011002NABISCO 9PCS13AmbientNormal4X102005A02-05-040
1610013522AIMONO 70g14AmbientNormal2X201005F02-01-011
17301054.600.684500671Total:
18
10048996



See my next reply for the macro code and instructions.
 
Upvote 0
miracleyy,

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:
Sub DistributeRowsV2()
' hiker95, 06/25/2014, ME785238
Dim w1 As Worksheet, ws As Worksheet, w As String
Dim Area As Range, r As Long, lr As Long, sr As Long, er As Long, nr As Long
Application.ScreenUpdating = False
Set w1 = Sheets("Sheet1")
With w1
  lr = .Cells(Rows.Count, 1).End(xlUp).Row
  For r = lr To 3 Step -1
    If .Cells(r, 1) = "Pick No:" Then .Rows(r).Insert
  Next r
End With
For Each Area In w1.Range("A1", w1.Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeConstants).Areas
  With Area
    sr = .Row
    er = sr + .Rows.Count - 1
    w = w1.Cells(sr, 4).Value
    If Not WorksheetExists(w) Then
      Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = w
    End If
    Set ws = Sheets(w)
    w1.Range("A" & sr & ":J" & er).Copy ws.Cells(1, 1)
    Application.CutCopyMode = False
    ws.Columns.AutoFit
  End With
Next Area
With w1
  On Error Resume Next
  .Range("A1", .Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
  On Error GoTo 0
  .Activate
End With
Application.ScreenUpdating = True
End Sub
Function WorksheetExists(w As String) As Boolean
On Error Resume Next
WorksheetExists = Worksheets(w).Name = w
On Error GoTo 0
End Function

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 DistributeRowsV2 macro.
 
Upvote 0
miracleyy,

Thanks for the feedback.

You are very welcome. Glad I could help.

And, come back anytime.
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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