adaytay
Mar 18 2004, 06:48 AM
Hi,
I'm sure I've seen this somewhere, but can someone remind me of the code to cycle through each sheet in the workbook in turn (I then want to overwrite all formulas with the values)
Any one assist?
Cheers,
Ad
Scomac
Mar 18 2004, 07:05 AM
this shuid do it nicely for u
Sub cycleWorksheets()
For Each w In Application.Worksheets '<- cant remember if this line is the correct one to use but it works
Debug.Print w.Name
w.Select
'eneter your paste special formula code here
Next
End Sub
KingMartin
Mar 18 2004, 07:43 AM
Hello Ad,
I believe this is what you want:
Sub LoopWs()
Dim ws As Worksheet
'
' you can hard-code the workbook if you like
For Each ws In ActiveWorkbook.Worksheets
ws.Range("A1") = 1
ws.Range("A2") = 1
ws.Range("A3").Formula = "=A1+A2"
Next ws
End Sub
adaytay
Mar 18 2004, 08:07 AM
Thanks... it was the "For Each ... In... " context I was after.
Cheers all!
Ad
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.