- Sub Template()
-
n = 1
-
Do While n > 0
-
Select Case Worksheets("Template(n)")
-
Case "Template(n)"
-
Worksheets("xxx") = Worksheets("Template(n)")
-
MsgBox ("set to same")
-
End Select
-
n = n + 1
-
Loop
-
End Sub
Do While n > 0
This will loop from 1 to infinity: it will take a long time.
Select Case Worksheets("Template(n)")
Case "Template(n)"
This is equivalent to an If clause:
If the worksheet whose name is Template(n) is equal to the string Template(n)
Note the n is just the letter n, it has nothing to do with the loop variable; ie, it will be the letter n for each iteration of the loop.
However, a worksheet is never going to equal a string, so the Select Case will always fail. Fortunately, it will fail with "Object doesn't support this property or method."
Worksheets("xxx") = Worksheets("Template(n)")
Sounds like a nice way to copy a worksheet, but it won't work, you will get "Object doesn't support this property or method."
So, your code does nothing forever. :D What do you want it to do?