Copying columns to new sheets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I hope you can help as I’m new to this programming lark!

I have a spreadsheet with data in Rows A to DI. What I would like to do is
copy the data from each row into a separate new sheet and rename the sheet
with the value in the second row. I think this should work on a loop but I
am not sure how. Thanks in advance.
 
I think you menat Columns A to DI. This code will copy the columns to column
A on each new worksheet. change "A:A" to a different column as required.


Sub newsheet()

LastColumn = Cells(2, Columns.Count).End(xlToLeft).Column
oldsheetname = ActiveSheet.Name
Set sheetnames = Sheets(oldsheetname). _
Range(Cells(2, "A"), Cells(2, LastColumn))

For Each cell In sheetnames
If cell <> oldsheetname Then

Worksheets.Add
ActiveSheet.Name = cell
cell.EntireColumn.Copy Destination:=ActiveSheet.Columns("A:A")
End If

Next cell

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top