New sheet for each item in column A

robertdseals

Active Member
Joined
May 14, 2008
Messages
337
Office Version
  1. 2010
Platform
  1. Windows
I have a spreadsheet. I'd like a new sheet for each item in column A The new sheet should be named after that item. (FYI the items will be something like 123456, 987654, etc). I would also like the contents of that row to be pasted into the corresponding sheet. Thoughts?
 
It is OK you added after, I am not here for an argument, I want people not just copy/paste code, I want them to understand why, and maybe them to come with a better solution, that is my purpose.

Regards,
GB
I added it a minute+ before you posted ;)
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Not all that much different from Mark's. Also without selecting which slows down the operation.
Also eliminated the flickering when changing sheets.
Amount of columns for each row can be variable.
Code:
Sub Make_Sheets()
Dim sh1 As Worksheet, nwSheet As Worksheet
Dim wb As Workbook
Dim c As Range
Dim lc As Long
Set wb = ThisWorkbook
Set sh1 = wb.Worksheets("Sheet1")
Application.ScreenUpdating = False
    For Each c In sh1.Range("A2:A" & sh1.Cells(sh1.Rows.Count, 1).End(xlUp).Row)
    lc = sh1.Cells(c.Row, sh1.Columns.Count).End(xlToLeft).Column
    
    If Not Evaluate("ISREF('" & c.Value & "'!" & c.Address & ")") Then wb.Worksheets.Add(After:=wb.Worksheets(Worksheets.Count)).Name = c.Value: _
        ActiveSheet.Range("A1").Resize(, lc - 1).Value = c.Offset(, 1).Resize(, lc - 1).Value
        
    Next c
sh1.Select
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

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