Loop - for each sheet not working?
Shetty
Try this
Sub All_Sheets_Loop()
Dim i As Integer
Dim sh
i = Worksheets.Count
For sh = 1 To i
Sheets(sh).Range("A1").Value = 10
Next
End Sub
Regards
Peter
-----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
.
|