Michael te Heesen
Michael te Heesen

Reputation: 1

VBA How to check if a worksheet name is number

I have entered the following code in my VBA sub:

Sub copy2sheet()
Dim wkSht As Worksheet    
    For Each wkSht In Sheets
        If IsNumeric(wkShrt.Name) Then
            Worksheets("Anleitung").Range("A1") = "a"
        Else
            Worksheets("Anleitung").Range("B1") = "a"
        End If
    Next
End Sub

I need to proceed in the following process only with those sheets, which have a numeric name (they are all of the form "yymmdd"). However, executing it gives me a 424 runtime error.

Any ideas?

Thanks!

Upvotes: 0

Views: 3760

Answers (1)

jpw
jpw

Reputation: 44881

You have a typo on line 4 which gives the Error 424 Object Required:

If IsNumeric(wkShrt.Name) Then

Should be

If IsNumeric(wkSht.Name) Then

Upvotes: 5

Related Questions