ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying columns to new sheets (https://www.excelbanter.com/excel-programming/392525-copying-columns-new-sheets.html)

Chris

Copying columns to new sheets
 
I hope you can help as Im 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.


joel

Copying columns to new sheets
 
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

"Chris" wrote:

I hope you can help as Im 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.



All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com