LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Configure macro to run on all sheets Excel 2k7

I have some simple code that selects a cell, enters a value, selects some
more cells and enters a formula. When i follow suggestions to configure the
code to run on all worksheets I cannot get it right. What it does is run the
code on the active sheet as many times as there are sheets. So it's looping
but not going on to the next sheet. Can someone tell me what I have wrong? I
have included the code that works (for the active sheet only) and the code i
think would work but won't.

Works:

Sub CalcDates()
ActiveSheet.Cells(2, 7).Select
Selection.Value = "Days"
ActiveSheet.Cells(3, 7).Select
Do While Not IsEmpty(ActiveCell.Offset(0, -1))
ActiveCell.FormulaR1C1 = "=DAYS360(RC[-4],RC[-6])"
ActiveCell.Offset(1, 0).Select
Loop
End Sub

Doesn't work:

Sub CalcDates()
For Each Worksheet In Worksheets
Cells(2, 7).Select
Selection.Value = "Days"
Cells(3, 7).Select
Do While Not IsEmpty(ActiveCell.Offset(0, -1))
ActiveCell.FormulaR1C1 = "=DAYS360(RC[-4],RC[-6])"
ActiveCell.Offset(1, 0).Select
Loop
Next Worksheet
End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why must I configure excel with every use tshahen Excel Discussion (Misc queries) 1 July 16th 09 05:15 PM
How can I configure EXCEL to do Ancova DaleB Excel Discussion (Misc queries) 3 December 27th 06 06:57 PM
How to configure Excel startup MS learner Excel Programming 1 January 27th 06 03:19 PM
Which Forumla and How do I configure in Excel? Ben Excel Discussion (Misc queries) 2 September 26th 05 11:34 PM
Can I configure Excel for not to respond on "F1" key press Murtaza Excel Discussion (Misc queries) 6 May 11th 05 01:00 PM


All times are GMT +1. The time now is 05:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"