View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_4_] Jim Thomlinson[_4_] is offline
external usenet poster
 
Posts: 1,119
Default Looping through Worksheets

You need to reference your range with the sheet object that is moving
throught the worksheets collection. So something like this...

Sub Loop_sheets()
Dim sh as worksheet

For each sh in activeworkbook.worksheets
sh.range("A1").value = "Tada"
'
Next sh

End sub


--
HTH...

Jim Thomlinson


"Steve" wrote:

If I am trying to place something in cell a1 using this code, I only get the
results on the active workbook.. What am I doing wrong?
Thanks,


"Hari Prasadh" wrote:

Hi Steve,

Sub Loop_sheets()
Dim sh as worksheet

For each sh in activeworkbook.worksheets
'
'
'
Next sh

End sub

Thanks a lot,
Hari
India

"Steve" wrote in message
...
Can someone lend some code that will allow me to open each worksheet in my
workbook through code, make a change to the worksheet and move to the next
until all worksheets have been updated. Then let me know the upate has
been
done to all worksheets in the workbook.

Thanks,