ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Script entry to add a new worksheet (https://www.excelbanter.com/excel-programming/430947-script-entry-add-new-worksheet.html)

oshanter

Script entry to add a new worksheet
 

Hi,

Could some kind person/people offer both specific and generic help with
Worksheet properties and events in script, but also specific help with

Moving from one worksheet to another, renaming worksheets tags and adding a
named worksheet.

I am a novice to Excel Scripting, although quite experienced with
spreadsheets since Lotus 123 (DOS).
--
Knowledge when shared becomes a gift. Thank you for your bounty.

Jacob Skaria

Script entry to add a new worksheet
 

Set the Security level to low/medium in (Tools|Macro|Security). From workbook
launch VBE using short-key Alt+F11. From menu 'Insert' a module and paste the
below code. Save. Get back to Workbook. Run macro from Tools|Macro|Run
<selected macro()..

Sub AddNewWorksheet()
Dim ws As Worksheet
Set ws = ActiveWorkbook.Sheets.Add(After:=ActiveSheet)
ws.Name = "NewName"
End Sub

Sub LoopthroughSheets()
For Each wsTemp In ActiveWorkbook.Sheets
MsgBox wsTemp.Name
wsTemp.Name = wsTemp.Name & "New"
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"oshanter" wrote:

Hi,

Could some kind person/people offer both specific and generic help with
Worksheet properties and events in script, but also specific help with

Moving from one worksheet to another, renaming worksheets tags and adding a
named worksheet.

I am a novice to Excel Scripting, although quite experienced with
spreadsheets since Lotus 123 (DOS).
--
Knowledge when shared becomes a gift. Thank you for your bounty.


Jacob Skaria

Script entry to add a new worksheet
 

Try the below 2 macros

Set the Security level to low/medium in (Tools|Macro|Security). From
workbook launch VBE using short-key Alt+F11. From menu 'Insert' a module and
paste the below code. Save. Get back to Workbook. Run macro from
Tools|Macro|Run <selected macro()

Sub InserNewSheet()
Dim ws As Worksheet
Set ws = ActiveWorkbook.Sheets.Add(After:=ActiveSheet)
ws.Name = "NewName"
End Sub

Sub LoopThroughSheets()
For Each wsTemp In ActiveWorkbook.Sheets
MsgBox wsTemp.Name
wsTemp.Name = wsTemp.Name & "New"
Next
End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"oshanter" wrote:

Hi,

Could some kind person/people offer both specific and generic help with
Worksheet properties and events in script, but also specific help with

Moving from one worksheet to another, renaming worksheets tags and adding a
named worksheet.

I am a novice to Excel Scripting, although quite experienced with
spreadsheets since Lotus 123 (DOS).
--
Knowledge when shared becomes a gift. Thank you for your bounty.


oshanter

Script entry to add a new worksheet
 

Jacob,

Thank you.

Tom
--
Knowledge shared is a gift. Thanks for your gift to me.


"Jacob Skaria" wrote:

Try the below 2 macros

Set the Security level to low/medium in (Tools|Macro|Security). From
workbook launch VBE using short-key Alt+F11. From menu 'Insert' a module and
paste the below code. Save. Get back to Workbook. Run macro from
Tools|Macro|Run <selected macro()

Sub InserNewSheet()
Dim ws As Worksheet
Set ws = ActiveWorkbook.Sheets.Add(After:=ActiveSheet)
ws.Name = "NewName"
End Sub

Sub LoopThroughSheets()
For Each wsTemp In ActiveWorkbook.Sheets
MsgBox wsTemp.Name
wsTemp.Name = wsTemp.Name & "New"
Next
End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"oshanter" wrote:

Hi,

Could some kind person/people offer both specific and generic help with
Worksheet properties and events in script, but also specific help with

Moving from one worksheet to another, renaming worksheets tags and adding a
named worksheet.

I am a novice to Excel Scripting, although quite experienced with
spreadsheets since Lotus 123 (DOS).
--
Knowledge when shared becomes a gift. Thank you for your bounty.



All times are GMT +1. The time now is 10:03 PM.

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