Loop - for each sheet not working?
Sub All_Sheets_Loop()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
sh.Range("A1").Value = 10
Next
End Sub
'sh' is the worksheet that you want to work on. No need
for it to be the active sheet, and in your code,
activesheet refers to the er, active sheet only.
Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
I want a value to be written to same cell of all the
sheets. I have
following macro written.
===========
Sub All_Sheets_Loop()
Dim i As Integer
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
ActiveSheet.Range("A1").Value = 10
Next
End Sub
===========
Above macro writes only in the active sheet and other
sheets are not
written by the value.
If I add a line activate.sheet it gives error.
Any thoughts pl?
Shetty
.
|