View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default macro to continue running if error

Hi,

Not very elegant but it works. Look out for the line wrap on the string of
sheet names


Public sh As Worksheet
Sub UpdateAll()
S =
"1,2,3,4,5,6,7,10,11,12,21,22,23,24,25,26,27,28,29 ,30,31,41,42,43,44,45,46,47,48,49,50,51,52,53,54,5 5,61"
V = Split(S, ",")
For Each sh In ActiveWorkbook.Worksheets
If Not IsError(Application.Match(sh.Name, V, 0)) Then
Call filter
End If
Next
End Sub

Sub filter()
MsgBox "Filter " & sh.Name
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Norvascom" wrote:

Hi,

I have the following macro that is working fine. It is looking at a
specified worksheet array and executing the macro "Filter" on each
worksheets. However, in case one of the worksheet is not existing, I
would like the macro to pass the non existing worksheet and continue
running on the next available worksheet. I tried adding the following
statement: "On Error Resume Next" at the beginning but it is passing
everything.

Any help would be appreciated.
Thanks

Sub UpdateAll()
For Each sh In Worksheets(Array("1", "2", "3", "4", "5", "6", "7",
"10", "11", "12", "21", "22", _
"23", "24", "25", "26", "27", "28", "29", "30", "31", "41", "42",
"43", "44", "45", "46", _
"47", "48", "49", "50", "51", "52", "53", "54", "55", "61"))
sh.Select
Call Filter
Next sh
End Sub
.