Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Not cycling through each sheet

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael Smith - 20 Jan 2006 17:31 GMT
This code is not working for me...I want to cycle through each sheet in
my workbook and run and IF statement.  It is not cycling through my
sheets, please help! TIA! - mike

   Range("A1").Select
   Selection.End(xlDown).Select
   Dim TodaysDate
   TodaysDate = ActiveCell.Text

   Dim WbMain As Workbook
   Dim wb As Workbook
   Dim Sh As Worksheet
   
   Application.ScreenUpdating = False
   Application.EnableEvents = False

   Set WbMain = ActiveWorkbook
   For Each Sh In WbMain.Worksheets
           Range("A1").Select
           Selection.End(xlDown).Select
           If ActiveCell.Value = TodaysDate Then
   Range("A1").End(xlDown).Offset(1, 0).FormulaR1C1 = "=today()"
   Range("A1").End(xlDown).Offset(0, 1).Formula = "0"
   Columns("A:A").Select
   Selection.Copy
   Selection.PasteSpecial Paste:=xlPasteValues
   Range("A1").Select
       End If
   Next Sh
Toppers - 20 Jan 2006 17:46 GMT
Hi,
        Try:

For Each Sh In WbMain.Worksheets
        sh.activate

> This code is not working for me...I want to cycle through each sheet in
> my workbook and run and IF statement.  It is not cycling through my
[quoted text clipped - 27 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***
Don Guillett - 20 Jan 2006 18:14 GMT
try this from anywhere in the workbook.
Sub dobetter()
td = sheets("sheet1").Cells(Rows.Count, "a").End(xlUp)
For Each Sh In Worksheets
slr = Sh.Cells(Rows.Count, "a").End(xlUp).Row
If Sh.Name <> "Sheet1" And Sh.Cells(slr, 1) = td Then
 Sh.Range("a1:a" & slr) = Date
 Sh.Range("b2:b" & slr) = 0
End If
Next Sh
End Sub

Signature

Don Guillett
SalesAid Software
dguillett1@austin.rr.com

> This code is not working for me...I want to cycle through each sheet in
> my workbook and run and IF statement.  It is not cycling through my
[quoted text clipped - 27 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***
Michael Smith - 20 Jan 2006 18:26 GMT
both work wonderfully...thank you mucho.
Don Guillett - 20 Jan 2006 19:46 GMT
Please take notice of the fact that it is NOT necessary to activate or
select. Both are poor coding practices that only slow down the process.

Signature

Don Guillett
SalesAid Software
dguillett1@austin.rr.com

> both work wonderfully...thank you mucho.
>
> *** Sent via Developersdex http://www.developersdex.com ***
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.