Script entry to add a new worksheet

O

oshanter

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).
 
J

Jacob Skaria

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
 
J

Jacob Skaria

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top