close

I have a workbook that I need to add a Worksheet called quot;CurWorkPadquot; to.

Right now I can insert a worksheet and it will come up named quot;Sheetxquot;, where
x=a number that increments each time a sheet is inserted. I also have code
to rename a worksheet, but it requires you to know the current name of the
inserted worksheet.

Is there a way to insert a new worksheet and rename it at the same time
without knowing what excel named the new worksheet?

Thanks for any help.
Mikewhen you insert the worksheet the new worksheet becomes selected
automatically, so you can use this to rename the new sheet

ActiveSheet.Name = quot;New_Namequot;

quot;Mikequot; wrote:

gt; I have a workbook that I need to add a Worksheet called quot;CurWorkPadquot; to.
gt;
gt; Right now I can insert a worksheet and it will come up named quot;Sheetxquot;, where
gt; x=a number that increments each time a sheet is inserted. I also have code
gt; to rename a worksheet, but it requires you to know the current name of the
gt; inserted worksheet.
gt;
gt; Is there a way to insert a new worksheet and rename it at the same time
gt; without knowing what excel named the new worksheet?
gt;
gt; Thanks for any help.
gt; Mike
gt;

Worked Great. Thanks.

Mikequot;flow23quot; wrote:

gt; Try this
gt;
gt; Sub addsheet()
gt; Sheets.Add.Name = quot;CurWorkPadquot;
gt; End Sub
gt;
gt; change quot; curworkpadquot; to any name you want
gt;
gt;
gt;
gt; quot;Mikequot; wrote:
gt;
gt; gt; I have a workbook that I need to add a Worksheet called quot;CurWorkPadquot; to.
gt; gt;
gt; gt; Right now I can insert a worksheet and it will come up named quot;Sheetxquot;, where
gt; gt; x=a number that increments each time a sheet is inserted. I also have code
gt; gt; to rename a worksheet, but it requires you to know the current name of the
gt; gt; inserted worksheet.
gt; gt;
gt; gt; Is there a way to insert a new worksheet and rename it at the same time
gt; gt; without knowing what excel named the new worksheet?
gt; gt;
gt; gt; Thanks for any help.
gt; gt; Mike
gt; gt;

Try this

Sub addsheet()
Sheets.Add.Name = quot;CurWorkPadquot;
End Sub

change quot; curworkpadquot; to any name you want
quot;Mikequot; wrote:

gt; I have a workbook that I need to add a Worksheet called quot;CurWorkPadquot; to.
gt;
gt; Right now I can insert a worksheet and it will come up named quot;Sheetxquot;, where
gt; x=a number that increments each time a sheet is inserted. I also have code
gt; to rename a worksheet, but it requires you to know the current name of the
gt; inserted worksheet.
gt;
gt; Is there a way to insert a new worksheet and rename it at the same time
gt; without knowing what excel named the new worksheet?
gt;
gt; Thanks for any help.
gt; Mike
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()