copy paste specific content

excelnoobhere

Board Regular
Joined
Mar 11, 2019
Messages
61
I'm looking for a code that will copy certain columns and paste them into a new sheets that will be created based on cell value.
for example lets say I have a huge list of data in cell A contain
A
5555-01-120-121
5555-01-120-123
5555-02-120-255
5555-05-150-220

I would like to be able to search through all of an and if A contain -01- then that gets copied that row's columns (A,B,O) into a new sheet columns (A,B,C) titled -01-, and if it contains -02- then creates a new sheet and does the same and so on for -05-

basically I want to split these data based on the value I have in red

how can I go about this?

any help would be much appreciated
 
The first reason that it doesn't work is the data in you op does not match the data in your sheet!!!
The second reason is that you have merged cells. These are a complete & utter nightmare & should be avoided like the plague.

First, are you happy to get rid of the merged cells?
Second what should happen with data like
Line: 51103-01 2019_GM_JBSCI BIW Lowers
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
The first reason that it doesn't work is the data in you op does not match the data in your sheet!!!
The second reason is that you have merged cells. These are a complete & utter nightmare & should be avoided like the plague.

First, are you happy to get rid of the merged cells?
Second what should happen with data like
Line: 51103-01 2019_GM_JBSCI BIW Lowers

I do apologize for that I'm new here so don't know much

through the sheet there are lines that contain random words sometimes just one word,
if then contain anything like
Line: 51103-01 2019_GM_JBSCI BIW Lowers <------- thats just a header title indicating the start of 01

if possible then ignore it

only focus on numbers
 
Upvote 0
Try
Code:
Sub excelnoobhere()
   Dim Cl As Range
   Dim Uniq As String
   Dim Ky As Variant
   Dim ws As Worksheet
   
   Set ws = Sheets("Master")
   With CreateObject("scripting.dictionary")
      For Each Cl In ws.Range("A3", ws.Range("A" & Rows.Count).End(xlUp))
         If IsNumeric(Left(Cl, 5)) Then
            Uniq = Mid(Cl, 6, 4)
            If Uniq <> "" Then .Item(Uniq) = Empty
         End If
      Next Cl
      For Each Ky In .Keys
         ws.Range("A2:O2").AutoFilter 1, "*" & Ky & "*"
         Sheets.Add(, Sheets(Sheets.Count)).Name = Ky
         Intersect(ws.AutoFilter.Range.EntireRow, ws.Range("A:B,O:O")).Copy Range("A1")
      Next Ky
      ws.AutoFilterMode = False
   End With
End Sub
 
Upvote 0
Code:
Try
Code:
Sub excelnoobhere()
   Dim Cl As Range
   Dim Uniq As String
   Dim Ky As Variant
   Dim ws As Worksheet
   
   Set ws = Sheets("Master")
   With CreateObject("scripting.dictionary")
      For Each Cl In ws.Range("A3", ws.Range("A" & Rows.Count).End(xlUp))
         If IsNumeric(Left(Cl, 5)) Then
            Uniq = Mid(Cl, 6, 4)
            If Uniq <> "" Then .Item(Uniq) = Empty
         End If
      Next Cl
      For Each Ky In .Keys
         ws.Range("A2:O2").AutoFilter 1, "*" & Ky & "*"
         Sheets.Add(, Sheets(Sheets.Count)).Name = Ky
         Intersect(ws.AutoFilter.Range.EntireRow, ws.Range("A:B,O:O")).Copy Range("A1")
      Next Ky
      ws.AutoFilterMode = False
   End With
End Sub

it worked with the sheet that i made up however, its not working with the real sheet that i want it to work with.
this sheet will follow this exact format with scrolling lock and tiles.
look at the uploaded sheet, keeps getting an error

https://www.dropbox.com/s/vqfybegtho6a8g0/test22.xlsx?dl=0

also thank thank you so much for your time and help
 
Upvote 0
What error message do you get & what line is highlighted when you click debug?
 
Upvote 0
What is the FULL error message?
when you get the error click on the button marked Debug & it will take you to the code with one line highlighted in yellow. Which line?
 
Upvote 0
What is the FULL error message?
when you get the error click on the button marked Debug & it will take you to the code with one line highlighted in yellow. Which line?

once the error dialog box pops up it doesn't let me click on debug however, I went through and stepped into it goes through the loop creates the page and it stops right when the page is created

I think this line
Code:
Intersect(ws.AutoFilter.Range.EntireRow, ws.Range("A:B,O:O")).Copy Range("A1")
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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