ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro for naming sheets? (https://www.excelbanter.com/excel-discussion-misc-queries/102941-macro-naming-sheets.html)

Olle Svensson

Macro for naming sheets?
 
I've just created a macro assigned to a button that creates a copy of a
sheet. Now, I would like to add a line or two of code in that macro that
changes the name of the newly created sheet to what is written in a cell on a
different sheet.

Is this in any way possible?

Ron de Bruin

Macro for naming sheets?
 
Try this

Sub test()
ActiveSheet.Copy after:=Sheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = Sheets("Sheet1").Range("A1").Value
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Olle Svensson" wrote in message ...
I've just created a macro assigned to a button that creates a copy of a
sheet. Now, I would like to add a line or two of code in that macro that
changes the name of the newly created sheet to what is written in a cell on a
different sheet.

Is this in any way possible?





All times are GMT +1. The time now is 07:39 AM.

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