View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Worksheet loop won't loop

Sub WorksheetLoop()
Dim WS_Count As Integer
Dim I As Integer

WS_Count = ActiveWorkbook.Worksheets.Count

For I = 1 To WS_Count
' you left this out
Worksheets(i).Activate
Range("IV4").End(xlToLeft).Offset(0, 1).Value = _
Range("IV4").End(xlToLeft).Value + 1
Range("IV13").End(xlToLeft).Resize(6, 1).Copy _
Range("IV13").End(xlToLeft).Offset(0, 1)

Next I
End Sub

--
Regards,
Tom Ogilvy


"L. Howard Kittle" wrote in message
...
Hello Excell Experts and Users,

When I run this code, it runs 10 times on the first sheet. I have 10

sheets
in the workbook. Tried it on three different workbooks, in a module, in

the
ThisWorkbook module and in the first sheet module.

This is pretty basic but it has me baffled...?

Sub WorksheetLoop()
Dim WS_Count As Integer
Dim I As Integer

WS_Count = ActiveWorkbook.Worksheets.Count

For I = 1 To WS_Count

Range("IV4").End(xlToLeft).Offset(0, 1).Value = _
Range("IV4").End(xlToLeft).Value + 1
Range("IV13").End(xlToLeft).Resize(6, 1).Copy _
Range("IV13").End(xlToLeft).Offset(0, 1)

Next I
End Sub

Thanks for any help.
Regards,
Howard