ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   how do i get the name of a newly added sheet that i add with Sheets.Add in a vba macro in excel? (https://www.excelbanter.com/excel-worksheet-functions/32193-how-do-i-get-name-newly-added-sheet-i-add-sheets-add-vba-macro-excel.html)

Daniel

how do i get the name of a newly added sheet that i add with Sheets.Add in a vba macro in excel?
 
how do i get the name of a newly added sheet that i add with Sheets.Add in a
vba macro in excel?



Alex

Daniel

This is one way, but maybe not wholly satisfactory...this is a starting
point (maybe) and you can tweak it...

Sub getShtName()
Dim shtCount As Integer
Dim newSht As String
shtCount = Worksheets.Count
Sheets.Add.Move After:=Sheets(shtCount)
newSht = Worksheets(shtCount + 1).Name
End Sub

This places a new sheet at the end and then gets the name of it.

"Daniel" wrote:

how do i get the name of a newly added sheet that i add with Sheets.Add in a
vba macro in excel?





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

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