View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default Loop - for each sheet not working?

I just created this using the macro recorder to select all sheets.
Just change one line as shown by removinging the one with the comment
Sub Macro1()
' Macro recorded 1/13/2004 by Don Guillett

' Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5")).Select
sheets.select ' selects all instead of array above

Sheets("Sheet1").Activate
Range("A1").Select
ActiveCell.FormulaR1C1 = "3"
Sheets("Sheet2").Select
End Sub

--
Don Guillett
SalesAid Software

"Shetty" wrote in message
om...
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