![]() |
Display current sheet name being processed in macro
I have the following macro that will protect each sheet in a workbook.
For n = 1 To Sheets.Count 'Sheets(n).Protect Password:="&PasswordEntered" Title = "Protecting sheet" Style = vbInformation MsgBox "Sheet Protected ", Style, Title Next n I need to display the sheet name back to the user, can someone suggest how I do that within the macro along with the msgbox? -- Thank U and Regards Ann |
Display current sheet name being processed in macro
Try your macro altered like this:-
Sub protect() For n = 1 To Sheets.Count Sheets(n).protect 'Password:="&PasswordEntered" Title = "Protecting sheet" Style = vbInformation Message = ActiveSheet.Name & " Protected" MsgBox Message, Style, Title Next n End Sub Mike "Ann" wrote: I have the following macro that will protect each sheet in a workbook. For n = 1 To Sheets.Count 'Sheets(n).Protect Password:="&PasswordEntered" Title = "Protecting sheet" Style = vbInformation MsgBox "Sheet Protected ", Style, Title Next n I need to display the sheet name back to the user, can someone suggest how I do that within the macro along with the msgbox? -- Thank U and Regards Ann |
Display current sheet name being processed in macro
OOPS missed a line
Sub protect() For n = 1 To Sheets.Count Sheets(n).protect 'Password:="&PasswordEntered" Sheets(n).Select Title = "Protecting sheet" Style = vbInformation Message = ActiveSheet.Name & " Protected" MsgBox Message, Style, Title Next n End Sub "Ann" wrote: I have the following macro that will protect each sheet in a workbook. For n = 1 To Sheets.Count 'Sheets(n).Protect Password:="&PasswordEntered" Title = "Protecting sheet" Style = vbInformation MsgBox "Sheet Protected ", Style, Title Next n I need to display the sheet name back to the user, can someone suggest how I do that within the macro along with the msgbox? -- Thank U and Regards Ann |
Display current sheet name being processed in macro
Mike,
I copied your code and it displays the Active Sheet Name (say sheet1) every time. I want the macro to display the sheet name as it goes through the workbook. Any ideas? -- Thank U and Regards Ann "Mike" wrote: Try your macro altered like this:- Sub protect() For n = 1 To Sheets.Count Sheets(n).protect 'Password:="&PasswordEntered" Title = "Protecting sheet" Style = vbInformation Message = ActiveSheet.Name & " Protected" MsgBox Message, Style, Title Next n End Sub Mike "Ann" wrote: I have the following macro that will protect each sheet in a workbook. For n = 1 To Sheets.Count 'Sheets(n).Protect Password:="&PasswordEntered" Title = "Protecting sheet" Style = vbInformation MsgBox "Sheet Protected ", Style, Title Next n I need to display the sheet name back to the user, can someone suggest how I do that within the macro along with the msgbox? -- Thank U and Regards Ann |
Display current sheet name being processed in macro
One way:
Dim n As Long For n = 1 To Sheets.Count With Sheets(n) .Protect Password:="&PasswordEntered" MsgBox Prompt:= .Name & " Protected", _ Title:="Protecting Sheet", _ Buttons:=vbInformation End WIth Next n In article , Ann wrote: I have the following macro that will protect each sheet in a workbook. For n = 1 To Sheets.Count 'Sheets(n).Protect Password:="&PasswordEntered" Title = "Protecting sheet" Style = vbInformation MsgBox "Sheet Protected ", Style, Title Next n I need to display the sheet name back to the user, can someone suggest how I do that within the macro along with the msgbox? |
Display current sheet name being processed in macro
Mike, JE,
Thank U for your kind assistance. -- Thank U and Regards Ann "JE McGimpsey" wrote: One way: Dim n As Long For n = 1 To Sheets.Count With Sheets(n) .Protect Password:="&PasswordEntered" MsgBox Prompt:= .Name & " Protected", _ Title:="Protecting Sheet", _ Buttons:=vbInformation End WIth Next n In article , Ann wrote: I have the following macro that will protect each sheet in a workbook. For n = 1 To Sheets.Count 'Sheets(n).Protect Password:="&PasswordEntered" Title = "Protecting sheet" Style = vbInformation MsgBox "Sheet Protected ", Style, Title Next n I need to display the sheet name back to the user, can someone suggest how I do that within the macro along with the msgbox? |
All times are GMT +1. The time now is 09:42 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com