Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Loop problems

this locks up Excel

Is it because I'm running a loop within an If, Then, Else?

Sub Timer()
Application.Wait Now + TimeValue("00:00:01")
Run_Time_and_Sales2
End Sub

Sub Run_Time_and_Sales2()

Dim LastPrint As Integer
Dim PrintTime As Double
Dim I As Integer

I = 1

LastPrint = Range("A" & I).Value
PrintTime = Range("B" & I).Value


If Range("F1") = "x" Then
Do
Loop While I < 26
Range("D4") = LastPrint
Range("E4") = PrintTime
I = I + 1
Else: End
End If

Timer

End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200706/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Loop problems

On Sat, 23 Jun 2007 22:54:14 +0100, blackbox via OfficeKB.com <u20390@uwe
wrote:

Do
Loop While I < 26
Range("D4") = LastPrint
Range("E4") = PrintTime
I = I + 1
Else: End


I think this should be:

Do
Range("D4") = LastPrint
Range("E4") = PrintTime
I = I + 1
Loop While I < 26



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Loop problems

That worked. Got it to run through with the time delay as well.
Thanks!

One more question, do you know how I can interrupt the loop from a command
button?
I was thinking maybe an event Change with a command button linked to a cell
and either a Case statement or an If, Then Else but haven't been able to make
it work.

Sub Run_Time_and_Sales()

Dim LastPrint As Integer
Dim PrintTime As Double

I = 1

If Range("F1") = "x" Then

Do

LastPrint = Range("A" & I).Value
PrintTime = Range("B" & I).Value

Range("D4") = LastPrint
Range("E4") = PrintTime
I = I + 1
Application.Wait Now + TimeValue("00:00:01")
Loop Until I 24

Else: End
End If

End Sub

--
Message posted via http://www.officekb.com

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
loop problems SYBS Excel Programming 6 April 12th 07 09:18 AM
Macro Help - Loop Problems ksp Excel Programming 2 May 1st 06 03:02 AM
problems with loop Arjan Excel Programming 1 December 8th 05 09:10 AM
for next loop problems cliee Excel Programming 3 November 1st 04 12:05 PM
Loop code problems pauluk[_51_] Excel Programming 2 April 23rd 04 10:30 AM


All times are GMT +1. The time now is 08:58 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"