Creating different sheets from data in the first sheet,

Jo4x4

Board Regular
Joined
Jan 8, 2011
Messages
136
Hi everybody! I have a very simple spreadsheet with all the data in sheet 1. I would like to split that data into different sheets. I tried vlookup, and can find the first match, but no second or third match.
Potholes
2/5/2017

<colgroup><col width="101" style="width:76pt"> </colgroup><tbody>
</tbody>
John
Streetlights8/6/ 2017Peter
Water leaks3/4/2017Dave
Potholes1/6/2017Adam
Potholes3/2/2017Pete

<tbody>
</tbody>

I then want sheets named "Potholes", "Streetlights", "Water Leaks" with the Pothole sheet containing the 3 instances and names.


Thanks a stack in advance!

Jo

Windows 7, Excel 2007
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
How about this
Code:
Sub ShtFltrCopy()

    Dim Dict As Object
    Dim Ky As Variant
    Dim Cl As Range
    Dim UsdRws As Long
    Dim Ws As Worksheet

Application.ScreenUpdating = False
    Set Dict = CreateObject("scripting.dictionary")

    With Sheets("Data")
        UsdRws = .Range("A" & Rows.Count).End(xlUp).Row
    
        For Each Cl In .Range("A2:A" & UsdRws)
            If Not Dict.exists(Cl.Value) Then Dict.Add Cl.Value, Nothing
        Next Cl
    
        For Each Ky In Dict.keys
            Set Ws = Worksheets.Add
            Ws.Name = Left(Ky, 31)
            .Range("A1").AutoFilter Field:=1, Criteria1:=Ky
            .Range("A1:C" & UsdRws).SpecialCells(xlVisible).Copy Ws.Range("A1")
        Next Ky
        .AutoFilterMode = False
    End With

End Sub
Changing sheets names & ranges as required
 
Last edited:
Upvote 0
Hi, Thanks for your time and effort. Please understand that I know very little about all of this. I have changed the sheet name to 2017 which is my main data sheet. I get a "400" error??

Jo
 
Upvote 0
If you hit debug, when the error occurs, what line was highlighted?
 
Upvote 0
It gives a 400 error without debugging. If I try to debug line by line it stops at the very first line: Sub ShtFltrCopy()
 
Upvote 0
Not sure what the error 400 is about.
Is the macro in the workbook containing the data?
Is there any sheet or workbook protection?
Are the Potholes etc in column A starting in row 2 with a header in row 1?
 
Upvote 0
Hi, yes, the macro is in the same workbook.
No sheet or workbook protection.
Yip, Column A starts from row 2 with the header in row 1.

Thanks again
 
Upvote 0
Strange, would you be able to post a copy of your workbook to Onedrive, or Google Drive?
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,694
Members
448,979
Latest member
DET4492

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