#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 23
Default Loop worksheets

Hi,

I have the following code:
Sub Hardcode()
For Each wks In ActiveWorkbook.Sheets
If Range("A4").Value < 400 Then
Call PriorYr
Call Actuals
Call Budget
Call Forecast
Else
End If
Next wks
Call Delete_Datasheets
End Sub

As far as I can see it's all correct, but the sheets aren't looping (next
wks not working). Does anyone know why or have any suggestions?
The total number of sheets in the workbook varies.

Thanks
merry_fay
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default Loop worksheets

You didn't say which worksheet range to check.

Sub Hardcode()
For Each wks In ActiveWorkbook.Sheets
If wks.Range("A4").Value < 400 Then
Call PriorYr
Call Actuals
Call Budget
Call Forecast
Else
End If
Next wks
Call Delete_Datasheets
End Sub

--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"merry_fay" wrote:

Hi,

I have the following code:
Sub Hardcode()
For Each wks In ActiveWorkbook.Sheets
If Range("A4").Value < 400 Then
Call PriorYr
Call Actuals
Call Budget
Call Forecast
Else
End If
Next wks
Call Delete_Datasheets
End Sub

As far as I can see it's all correct, but the sheets aren't looping (next
wks not working). Does anyone know why or have any suggestions?
The total number of sheets in the workbook varies.

Thanks
merry_fay

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Loop worksheets

Hi,

the sheets are looping but not the range, try this line

If wks.Range("A4").Value < 400 Then

Mike

"merry_fay" wrote:

Hi,

I have the following code:
Sub Hardcode()
For Each wks In ActiveWorkbook.Sheets
If Range("A4").Value < 400 Then
Call PriorYr
Call Actuals
Call Budget
Call Forecast
Else
End If
Next wks
Call Delete_Datasheets
End Sub

As far as I can see it's all correct, but the sheets aren't looping (next
wks not working). Does anyone know why or have any suggestions?
The total number of sheets in the workbook varies.

Thanks
merry_fay

Reply
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
For Each Loop jbjtc Excel Discussion (Misc queries) 8 September 20th 07 01:28 PM
if & Loop steven.holloway Excel Discussion (Misc queries) 5 July 20th 07 09:50 AM
do..loop Anna Excel Discussion (Misc queries) 6 June 20th 07 01:10 PM
DO LOOP in VBA Brettjg Excel Discussion (Misc queries) 5 April 24th 07 12:42 AM
Next w/o For If/Then Loop littlegreenmen1 Excel Discussion (Misc queries) 5 June 9th 05 05:28 PM


All times are GMT +1. The time now is 09:40 PM.

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

About Us

"It's about Microsoft Excel"