Problem copying rows to new worksheets

TheDudeAbides1987

New Member
Joined
Mar 27, 2013
Messages
3
I have a lot, a lot of data to sort. I need to search column U for products and then move the row information to a new workbook for each product. There are over 1,000 different products and each one has numerous entries that are randomly distrusted within column U.

So far this is what I have but I am getting run time error 9

Option Explicit
Sub sd()
Dim prod() As String
Dim myr As Range
Dim x As Integer
Dim prods As Integer
x = 0

For Each myr In Range("BE2", Range("BE2").End(xlDown))
If myr <> myr.Offset(1, 0) Then x = x + 1
Next myr
ReDim prod(x)
x = 0
For Each myr In Range("U2", Range("U2").End(xlDown))
If myr <> myr.Offset(1, 0) Then
x = x + 1
prod(x) = myr
End If
Next myr
prods = x
For x = 1 To prods
Sheets("MBSchoolSalesq12011").Copy after:=Sheets("MBSchoolSalesq12011")
ActiveSheet.Name = prod(x)
Rows("1:1").AutoFilter
Rows("1:1").AutoFilter field:=12, Criteria1:="<>" & prod(x)

Cells.SpecialCells(xlCellTypeVisible).Delete
Rows(1).Insert
Range("a1").Resize(1, 9).Value = Array("Header 1", "Header 2", "Header 3", "Header 4", "Header 5", "Header 6", "Header 7", "Header 8", "Header 9")
Rows("1:4").Insert
Range("a1") = "Product Type: " & prod(x)
Next x
End Sub
 

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
I figured out the Run time error 9.

Now it is having problems with the line:
If myr <> myr.Offset(1, 0) Then x = x + 1

It says run time error 1004; application-defined or object defined error
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,640
Members
448,974
Latest member
DumbFinanceBro

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