rpaulson
Well-known Member
- Joined
- Oct 4, 2007
- Messages
- 1,428
I see a lot of request for some VBA code to create individual sheets out of my data. (Like: "I want a sheet for every part number in my list")
I put together some code to automate the process for you.
Enjoy!
-Ross
I put together some code to automate the process for you.
Enjoy!
VBA Code:
Sub Create_Worksheets()
'This macro will seperate the data in your range into individual worksheet(s)
'it will look in Column "A" of every row in your data
'it will then add that row of data into a worksheet whose sheet name is the value in columnn "A"
'if the worksheet does not exist, the code will automatically create and name the new sheet for you.
Dim rs As Worksheet
Set rs = ActiveSheet
For r = 1 To rs.Range("A" & Rows.Count).End(xlUp).Row
wsName = rs.Cells(r, "A") '<<<<<<<<<<<<<<<<<<<<< Change this to the column that you would like to seperate
If wsName = "" Then GoTo 10
If WorksheetFunction.IsErr(Evaluate("'" & wsName & "'!A1")) = "True" Then Sheets.Add.Name = wsName 'if true then sheet does NOT exist, if False then sheet does exist
wr = Worksheets(wsName).Range("A" & Rows.Count).End(xlUp).Row + 1
rs.Rows(r).Copy Destination:=Worksheets(wsName).Range("A" & wr)
10 Next r
rs.Activate
MsgBox "Done"
End Sub
-Ross