![]() |
Macro - Auto - Sheet Name change ? expiry
1 . I want to change sheet name automatically by running macro (VB code)
if sheet name = x then sheet name will be changed to y after openning the file automatically. can u pls give me the code? -------------------------------------------------------- 2. if i want to trigger a macro on any change in sheet 1, what is the code? |
Macro - Auto - Sheet Name change ? expiry
1. Use the following (attach it to ThisWorkbook code)
Private Sub Workbook_Open() For Each ws In Worksheets If ws.Name = "Sheet1" Then ws.Name = "New Name" End If Next End Sub 2. Use Private Sub Worksheet_Change(ByVal Target As Range) 'Following will run only if there is a change in the range A1:A10 If Not Intersect(Target, Range("A1:A10")) Is Nothing Then 'Your code here... End If End Sub "Som" wrote: 1 . I want to change sheet name automatically by running macro (VB code) if sheet name = x then sheet name will be changed to y after openning the file automatically. can u pls give me the code? -------------------------------------------------------- 2. if i want to trigger a macro on any change in sheet 1, what is the code? |
Macro - Auto - Sheet Name change ? expiry
DearSom
Use the workbook open event and try this code. Private Sub Workbook_Open() Sheets("x").Name = "y" End Sub If this post helps click Yes -------------- Jacob Skaria "Som" wrote: 1 . I want to change sheet name automatically by running macro (VB code) if sheet name = x then sheet name will be changed to y after openning the file automatically. can u pls give me the code? -------------------------------------------------------- 2. if i want to trigger a macro on any change in sheet 1, what is the code? |
Macro - Auto - Sheet Name change ? expiry
To trigger a macro for change.
Use the below event. Launch VBE using Alt+F11. Insert Module. Double click sheet1 in treeview, drop down to see the below event. You can use the same event in 'Thisworkbook' to trigger this from anysheet in the workbook.. Private Sub Worksheet_Change(ByVal Target As Range) End Sub If this post helps click Yes -------------- Jacob Skaria "Som" wrote: 1 . I want to change sheet name automatically by running macro (VB code) if sheet name = x then sheet name will be changed to y after openning the file automatically. can u pls give me the code? -------------------------------------------------------- 2. if i want to trigger a macro on any change in sheet 1, what is the code? |
All times are GMT +1. The time now is 12:30 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com