Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've got my sub ClearDataWk() below to loop through all colored cells on the
active worksheet and delete data from colored cells. I also have a MsgBox warning to give the user a chance to make sure they wish to delete data. How can I insert some code to either exit or warn if the ActiveSheet is not contained within a specific list of worksheets? Something like: If ActiveSheet not in In Worksheets(Array("dataSheet1", "dataSheet2")) So if the ActiveSheet was "defaultVaues" the sub would display a warning Msgbox warning the user. CODE: ********************** Sub ClearDataWk() Dim cell As Range, sh As Worksheet Dim sMsg, iStyle, sTitle, Response sMsg = "Preparing to clear data from worksheet: " & ActiveSheet.Name & vbCrLf & _ "(note: You will not be able to undo this procedure)" & vbCrLf & vbCrLf & _ "Do you want to continue ?" iStyle = vbYesNo + vbQuestion + vbDefaultButton2 sTitle = "Clear Data" Response = MsgBox(sMsg, iStyle, sTitle) If Response = vbYes Then 'Continue ElseIf Response = vbNo Then Exit Sub End If For Each cell In ActiveSheet.UsedRange If cell.Interior.ColorIndex = 19 Then cell.ClearContents End If Next End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Test Initialization of an Array | Excel Programming | |||
Test for dups in Array | Excel Programming | |||
Array Test | Excel Programming | |||
Test for end of array of objects? | Excel Programming | |||
Test for Single Character That is in an Array | Excel Worksheet Functions |