Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

ms excel programing using vba

Status
Not open for further replies.

neo2083

Computer
Jul 18, 2003
1

how to create a new sheet (i.e.) one more & where to write
the code in which sheet coding?
 
Replies continue below

Recommended for you

The menu Insert|Worksheet item allows you to add sheets to a workbook.

Macros are associated with the workbook, not with the worksheet.

TTFN
 
The easiest way to determine this is to turn on macro recording, do the action, turn off recording and go look at the macro created.
 
This method works as a good place to start, but there are a number of Excel commands that are not recorded. Also, you should look at the help for that object because they way that the Macro recorder works is most often in my experience not the way that I need it to work. Thus, I often use this method only to get an idea of what I should do.
 
The command:

'ActiveWorkbook.Worksheets.Add'

will add a sheet before the active worksheet in the active workbook.

'Worksheets.Add.Move after:=Worksheets(Worksheets.Count)'

will add a sheet and move it to the end of all visible worksheets.
To get to the VB editor, go to 'Tools + Macro + Visual Basic Editor'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor