ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create a sheet and name it (https://www.excelbanter.com/excel-programming/348950-create-sheet-name.html)

[email protected]

Create a sheet and name it
 
I need to write a macro which does the following

1) Create a new sheet in the current workbook

2) Scan the current sheet split each row into several columns and write
them in new sheet.

I know how to scan the current sheet but my problem is how, from the
current sheet, referer to the sheet I need to use to add rows. It is
not a copy row by row as sometimes several rows will make one row on
the new sheet


Norman Jones

Create a sheet and name it
 
Hi JeanLuc,

Assign the new sheet to an object variable, e.g.:

'=============
Sub Tester()
Dim WB As Workbook
Dim srcSH As Worksheet
Dim destSH As Worksheet

Set srcSH = ActiveSheet
Set destSH = WB.Sheets.Add(After:=Sheets(WB.Sheets.Count))

'Your copy code, e.g.:
srcSH.Range("A1").Copy Destination:=destSH.Range("C1")
End Sub
'<<=============

---
Regards,
Norman



wrote in message
oups.com...
I need to write a macro which does the following

1) Create a new sheet in the current workbook

2) Scan the current sheet split each row into several columns and write
them in new sheet.

I know how to scan the current sheet but my problem is how, from the
current sheet, referer to the sheet I need to use to add rows. It is
not a copy row by row as sometimes several rows will make one row on
the new sheet





All times are GMT +1. The time now is 07:30 PM.

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