View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis[_3_] Dana DeLouis[_3_] is offline
external usenet poster
 
Posts: 690
Default macro to continue running if error

Hi. You would have to add a little more logic to this, but here's an
additional general idea:

Select Case Val(sh.Name)

Case 1 To 7, 10 To 12, 21 To 31 'etc
'Do Something
Case Else
'Do Nothing
End Select

= = = = = = =
HTH :)
Dana DeLouis

On 2/28/2010 8:42 PM, Norvascom wrote:
On Feb 28, 5:01 pm,
wrote:
My apologies. An error in the code I posted. It will work better if the
Select and Call are included within the Case instead of outside of it. Also
noted Dave's comment re Filter

Sub UpdateAll()
Dim sh As Worksheet
For Each sh In Worksheets

Select Case sh.Name

Case "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 macFilter

End Select

Next sh
End Sub

--
Regards,

OssieMac



"OssieMac" wrote:
I am assuming that the numbers are the actual sheet names and not the sheet
index number. If my assumption is correct then try the code below and there
will be no error.


Using Select Case, even though there is only one case, multiple names can be
used separated by a comma and in effect they become Or operators.


The reason for the error in your code is that if the sheet does not exist,
you cannot use it in the array in the For Each statement.


Sub UpdateAll()
Dim sh As Worksheet
For Each sh In Worksheets


Select Case sh.Name


Case "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"


End Select


sh.Select


Call Filter


Next sh
End Sub


--
Regards,


OssieMac- Hide quoted text -


- Show quoted text -



Thanks OssieMac