Monday, October 27, 2008

Rename, Delete a Excel sheet by using macro

Hi All,

Today we are discussed about how to rename or delete a worksheet by using macro.

Most of the people who used excel they want to know a short cut key for renaming or deleting a worksheet

Here i am tell you how you can make a short cut key for deleting or renaming a excel worksheet by using macros.

Open a new work book and then open the visual basic editor from tools menu.

Now insert a new module for insert your code.

Now copy and paste the following codes
For renaming a sheet:

Sub renamesheet()

Dim sheetname As String

sheetname = InputBox("Enter the new sheet Name")

ActiveSheet.Name = sheetname

End Sub


For deleting a sheet with out alerts:

Sub deletesheet()

On Error GoTo msg

Application.DisplayAlerts = True

ActiveSheet.Delete

End




msg:

MsgBox "This is the last sheet in the workbook, You cant delete it", vbOKOnly,
"Alerts"


End


End Sub





save your workbook.

You also can download and use the renaming and deliting work sheet addins from the following link

Rename_delete_sheet: Click Here

No comments:

Subscribe Now: From your browser

Search:

Learn Office Excel