UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Quick Query - Cycle through all sheets    
 
   
adaytay
post Mar 18 2004, 06:48 AM
Post #1

UtterAccess VIP
Posts: 3,656
From: Yorkshire, England.



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
Go to the top of the page
 
+
Scomac
post Mar 18 2004, 07:05 AM
Post #2

UtterAccess Guru
Posts: 969
From: Scotland



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
Go to the top of the page
 
+
KingMartin
post Mar 18 2004, 07:43 AM
Post #3

Retired Moderator
Posts: 10,959
From: Prague,CZ / Kiev,UA



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
Go to the top of the page
 
+
adaytay
post Mar 18 2004, 08:07 AM
Post #4

UtterAccess VIP
Posts: 3,656
From: Yorkshire, England.



Thanks... it was the "For Each ... In... " context I was after.

Cheers all!

Ad
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 25th May 2013 - 07:51 PM