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: 13
Default loop on visible cells only

I have following code that i wish to run on visible cells only.
the way i have it is slow can someone guide me in a better way to run
code on visible cells only.

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Check = True: counter = 0: r = 50 ' Initialize variables.
Do ' Outer loop.
Do While counter < 1137 ' Inner loop.
r = 50 + counter 'start row
c = 14 'start Column

CloseStk = Cells(r, c).Value
calczero = Cells(r - 2, c).Value - Cells(r - 3, c - 2).Value
MinWks = Val(Cells(r - 3, 11).Value) / 4
ERQ = Cells(r - 3, 9).Value
Demand = Cells(r - 2, c).Value
Demand1 = Cells(r - 2, c + 1).Value
Demand2 = Cells(r - 2, c + 2).Value
Demand3 = Cells(r - 2, c + 3).Value
Demand4 = Cells(r - 2, c + 4).Value
MthsC = Cells(r - 3, 10).Value
Prod = Cells(r - 1, c).Value
OpenStk = Cells(r, c - 1).Value

If Cells(r, c).EntireRow.Hidden = False Then

If Cells(r - 3, 1).Value = "Y" And Cells(r - 3, 2).Value = 1 Then

If CloseStk = 0 Then
If MthsC = 1 Then
If Demand1 0 Then
Cells(r - 1, c) = calczero + (Demand1 * MinWks)
Else: Cells(r - 1, c).Value = calczero
End If

ElseIf MthsC = 2 Then

...... code goes on and on ........

End If

End If
End If
End If
counter = counter + 4 ' Increment Counter.
If counter 1137 Then ' If condition is True.
Check = False ' Set value of flag to False.
Exit Do ' Exit inner loop.
End If
Loop
Loop Until Check = False ' Exit outer loop immediately.

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True


thanks for any help
Simon

 
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
Copy Visible Cells in Sheet with Merged and Hidden Cells rtwiss Excel Discussion (Misc queries) 5 April 25th 23 09:08 AM
Sum Visible Cells Julie Excel Worksheet Functions 5 February 26th 08 12:31 AM
AutoFilter: Loop Thru Visible Rows? Damian Carrillo[_2_] Excel Programming 2 July 21st 05 01:16 AM
Loop thru multiple files - Modify worksheet visible property Mike Taylor Excel Programming 1 October 24th 03 04:03 AM
Help: Copying Visible Cells only to Visible cells! Jay Jayakumar Excel Programming 0 July 9th 03 08:25 PM


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

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"