![]() |
Placing "DRAFT" just on Certain Sheets
The below code is perfect for toggling "DRAFT" on/off an
activesheet, but I need to modify it as follows. I'm lost as to which way to turn/go. Any assistance would be greatly appreciated. My workbook has several tabs (worksheets). I need to permanently place "DRAFT" on ALL worksheets (disallow toggling) that DO NOT have the word "NOTES" as part of the sheet name, example "IP-CUR NOTES" - Code would allow for additional tabs (sheets) being added. Thanks in Advance, JMay |
Placing "DRAFT" just on Certain Sheets
I'm not sure what you mean by placing "DRAFT" on each
sheet, in a particular cell? (the code you mentioned does not appear in this post). Whatever, perhaps you could try something like this: Sub Test() Dim ws As Worksheet Dim sNote As String sNote = "NOTES" For Each ws In ActiveWorkbook.Worksheets If InStr(1, ws.Name, sNote, 1) = 0 Then 'do code to place "DRAFTS" End If Next End Sub See InStr in help, change the last argument to zero for case sensitive comparison Code would allow for additional tabs (sheets) being added An Event is triggered when a new sheet is added, however it will be named "SheetX". Possibly within the event you could ask the user give a new sheet name via an Inputbox, then check the input string or run the above code. Regards, Sandy -----Original Message----- The below code is perfect for toggling "DRAFT" on/off an activesheet, but I need to modify it as follows. I'm lost as to which way to turn/go. Any assistance would be greatly appreciated. My workbook has several tabs (worksheets). I need to permanently place "DRAFT" on ALL worksheets (disallow toggling) that DO NOT have the word "NOTES" as part of the sheet name, example "IP-CUR NOTES" - Code would allow for additional tabs (sheets) being added. Thanks in Advance, JMay . |
Placing "DRAFT" just on Certain Sheets
Thanks Sandy;
Yes, in my confused state I forgot to copy in the "below code"; thanks for offering a viable alternative. JMay "Sandy-V" wrote in message ... I'm not sure what you mean by placing "DRAFT" on each sheet, in a particular cell? (the code you mentioned does not appear in this post). Whatever, perhaps you could try something like this: Sub Test() Dim ws As Worksheet Dim sNote As String sNote = "NOTES" For Each ws In ActiveWorkbook.Worksheets If InStr(1, ws.Name, sNote, 1) = 0 Then 'do code to place "DRAFTS" End If Next End Sub See InStr in help, change the last argument to zero for case sensitive comparison Code would allow for additional tabs (sheets) being added An Event is triggered when a new sheet is added, however it will be named "SheetX". Possibly within the event you could ask the user give a new sheet name via an Inputbox, then check the input string or run the above code. Regards, Sandy -----Original Message----- The below code is perfect for toggling "DRAFT" on/off an activesheet, but I need to modify it as follows. I'm lost as to which way to turn/go. Any assistance would be greatly appreciated. My workbook has several tabs (worksheets). I need to permanently place "DRAFT" on ALL worksheets (disallow toggling) that DO NOT have the word "NOTES" as part of the sheet name, example "IP-CUR NOTES" - Code would allow for additional tabs (sheets) being added. Thanks in Advance, JMay . |
All times are GMT +1. The time now is 12:21 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com