ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro assistance (https://www.excelbanter.com/excel-programming/333868-macro-assistance.html)

dthompson

Macro assistance
 

I am writing a macro that takes data from one table
adds it to another table, titles the new sheet and then loops down to
the next set of data and starts all over again.

My question is this:
How do I name the new sheet in the vba so it can recognize it through
out the code. This is what I am doing but I don't know how to call the
new sheet with the new name. Thanks for any suggestions on this method
or if there is a better way to go about this process.

Sheets("FlatCustomers").Select
Cells(2, 2).Select
Selection.Copy
Sheets.Add
Range("B3").Select
ActiveSheet.Paste
Range("B3").Select
ActiveSheet.Name = Range("B3").Value
Sheets("FlatCustomers").Select
Cells(3, 2).Select
Selection.Copy


--
dthompson
------------------------------------------------------------------------
dthompson's Profile: http://www.excelforum.com/member.php...o&userid=25002
View this thread: http://www.excelforum.com/showthread...hreadid=385268


dthompson[_2_]

Macro assistance
 

Disregard I figured it ou

--
dthompso
-----------------------------------------------------------------------
dthompson's Profile: http://www.excelforum.com/member.php...fo&userid=2500
View this thread: http://www.excelforum.com/showthread.php?threadid=38526


Bob Phillips[_7_]

Macro assistance
 
sNew = Range("B3").Value
Sheets.Add.Name = sNew
Sheets("FlatCustomers").Cells(2, 2).Copy Worksheets(sNew).Range("B3")
Sheets("FlatCustomers").Cells(3, 2).Copy Worksheets(sNew).Range("B4")
etc.

--
HTH

Bob Phillips

"dthompson" wrote
in message ...

I am writing a macro that takes data from one table
adds it to another table, titles the new sheet and then loops down to
the next set of data and starts all over again.

My question is this:
How do I name the new sheet in the vba so it can recognize it through
out the code. This is what I am doing but I don't know how to call the
new sheet with the new name. Thanks for any suggestions on this method
or if there is a better way to go about this process.

Sheets("FlatCustomers").Select
Cells(2, 2).Select
Selection.Copy
Sheets.Add
Range("B3").Select
ActiveSheet.Paste
Range("B3").Select
ActiveSheet.Name = Range("B3").Value
Sheets("FlatCustomers").Select
Cells(3, 2).Select
Selection.Copy


--
dthompson
------------------------------------------------------------------------
dthompson's Profile:

http://www.excelforum.com/member.php...o&userid=25002
View this thread: http://www.excelforum.com/showthread...hreadid=385268





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

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