I haven't tested this because i am not really sure what or where that code is supposed to be / do, but it may work.

Code:
Dim myWS as WorkSheet

For Each myWS in WorkSheets
  '....
  'Code
  '....
Next