How to split data into multiple worksheets based on column values in Excel?

wao5012

New Member
Joined
May 7, 2018
Messages
32
Good Afternoon All,

I have a excel file that contains two tabs ("Summary" Sheet 1) and ("AllBreaks" Sheet 2). I was wondering if anyone had a similar code that will split out the data on AllBreaks Sheet 2 into two buckets, If values in column N = "Working" and "Expecting" split onto sheet 3, if not equal to those two spilt onto sheet 4. Does anyone have a sample code that does something similar to this?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
You said:
into two buckets
What is a bucket?
You said you had two sheets and then named them but then you mentioned:
split onto sheet 3, if not equal to those two spilt onto sheet 4
So now it sounds like we have four sheets.
And what does "split" mean?
Do you mean copy this row to sheet 3 or sheet 4
And what is the name of these other two sheets.

And you do not mention what if anything we need to do with sheet named "
Summary
"
 
Upvote 0
Hey My Aswer Is This clarification is below thank you for your response

I am looking for a macros that can find cell values contained in a specific cell and paste the entire row on a new worksheet.

I have a Excel file that contains 2 Worksheets (Tabs). Worksheet 1 is irrelevant in this Macros. For Worksheet 2 (tab 2) I have 18 columns. I want to copy data from a specific column ("R" or 14) and paste the entire row into 2 new worksheets (2 new tabs in the same file) based on the cell values of column R. On Worksheet 3 (tab 3) should contain all the values NOT EQUAL to "WWC" or "ETOF". On Worksheet 4 (tab 4) should contain all values EQUAL to "WWC" or "ETOF".

Essentially, If cell values = WWC or ETOF paste row on Worksheet 4 ELSE paste on Worksheet 3.


I am trying to use the below script to achieve this. However it keeps failing returning an error message so something is failing. Not sure if the below is even the best approach. I was wondering if anyone knew how to achieve the above?

Sub SearchForString()


Dim LSearchRow As Integer
Dim LCopyToRow As Integer


On Error GoTo Err_Execute


'Start search in row 14
LSearchRow = 14


'Start copying data to row 2 in Sheet2 (row counter variable)
LCopyToRow = 2


While Len(Range("A" & CStr(LSearchRow)).Value) > 0


'If value in column E = "Mail Box", copy entire row to Sheet2
If Range("N" & CStr(LSearchRow)).Value = "Working w/Client" Or "Expecting Transaction on Overnight Feed" Then


'Select row in Sheet1 to copy
Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
Selection.Copy


'Paste row into Sheet2 in next row
Sheets("Sheet2").Select
Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
ActiveSheet.Paste


'Move counter to next row
LCopyToRow = LCopyToRow + 1


'Go back to Sheet1 to continue searching
Sheets("Sheet1").Select


End If


LSearchRow = LSearchRow + 1


Wend


'Position on cell A3
Application.CutCopyMode = False
Range("A3").Select


MsgBox "All matching data has been copied."


Exit Sub


Err_Execute:
MsgBox "An error occurred."


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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