View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Patrick C. Simonds Patrick C. Simonds is offline
external usenet poster
 
Posts: 343
Default Cycle through all workshhets

Thank you you are right. I thought by not going into to much detail I could
get something I could work with (adapt) without consuming to much of
everyone's time. Clearly that was not the case an I am very much out of my
league.

What I am trying to do is create a template of our vacation calendar which
when the year is changed would insert our allowed vacations (which are
represented by graphics shapes I have created). This workbook has 105
worksheets. Each worksheet is made up of either Monday - Wednesday or
Thursday - Sunday. The code below (which was provided by Peter T) goes to
the worksheet called Holidays and copies the shape (in this case the shape
representing New Years).

What I now need to do is have my code look through each of the worksheets
(excluding Holidays) at range("B56") and if it is equal to "New Years" paste
the shape into cell B19. If B56 does not equal "New Years" then it will
check cell E56 (with the shape going into cell E19) then cell H56 (with the
shape going into cell H19). Those test I feel I can write with out any
problems. But I can not get it to cycle through each of the 104 Worksheets.

I will also create a routine for the other 5 holidays through the year and
am assuming that they can be easily modeled on the New Years routine.



Sub NewYearsInsert()

Dim lt As Single, tp As Single
Dim rTL As Range
Dim shp As Shape
Dim rng As Range

Set shp = ActiveWorkbook.Worksheets("Holidays").Shapes("New Years
Large")

With shp
Set rTL = .TopLeftCell
lt = .Left - rTL.Left
tp = .Top - rTL.Top
.Copy
End With


End Sub



"JLGWhiz" wrote in message
...
Both Mike's and Dave's suggestions do cycle through the worksheets using
the
For...Next loop. All you have to do is put the code in between that does
the
pasting.
Dave even gave you some extra sample code to get you started with that.
If
you are a beginner in code writing, you should be specific and complete in
what you are trying to do. It is very difficult to sit hundreds of miles
away and guess at what you want to accomplish.

"Patrick C. Simonds" wrote:

I am not sure this is what I am looking for. I just want it to cycle
through each worksheet (I will set screen updating to false) and paste
data
into B19 of each worksheet.

"Mike" wrote in message
...
Sub cycleThruSheets()
Dim ws As Worksheet

For Each ws In Worksheets
MsgBox ws.name
Next ws
End Sub

"Patrick C. Simonds" wrote:

I need a piece of code that will cycle through each worksheet and
perform
a
Paste into cell B19 of each worksheet. I do not want to select all
worksheets but cycle through them. At some point I will be modifying
the
code to where if a certain condition is not met, the paste will not
take
place.