Thursday, April 12, 2012

Working with worksheets using VBA

Sub WorkSheetsDemo()

Sheets.Add 'It adds a new worksheet before the active sheet
'To add worksheet at last please use the below syntax
'Sheets.Add After:=Worksheets(Sheets.Count)
'To add a worksheet at required position, we can specify name of the worksheet
Sheets.Add After:=Worksheets("Sheet2")

'To Rename a worksheet
Sheets("sheet9").Name = "MySampleSheet"

End Sub

1 comment:

  1. How to import a excel sheet data into a mdb file. It should create table automatically.