Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Do while loop

I need to create a loop to test if the value "56A" exist. It should loop
until C<25. If "56A" exists, then call a function. If c reaches 25 and
"56A" does not exist, then call a different function.

I had this code created. It seems like both the happy and sad functions are
performed when "56A" is found.

What's a better method to put this code?

c = 10
Do While sValue < "56A" or c<25

If sValue = "56A" Then
call happy
Else
c = c + 1
End If

Loop
call sad
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Do while loop


Hi Vanna,

Not surprising. After "56A" is found and "Happy" called, the loop i
exited only to call "Sad" again. To avoid calling "Sad" after "Happy"
adjust your code thus:

c = 10
Do While sValue < "56A" or c<25

If sValue = "56A" Then
call happy
EXIT SUB ===== INSERTE
Else
c = c + 1
End If

Loop
call sad




Myle

--
Myle
-----------------------------------------------------------------------
Myles's Profile: http://www.excelforum.com/member.php...fo&userid=2874
View this thread: http://www.excelforum.com/showthread.php?threadid=52508

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Do while loop

Hi Myles,
thank you very much for answering to my post.
I tried your solution and it worked for me partially. Now I'm getting
information populated in my "Happy" worksheet, but I'm also getting
information populated for my "Sad" worksheet.

Perhaps I didn't explain my situation in enough detailed.

I have a do loop inside a do loop. Say, List of A to Z records
Inside each record, I need to extract field inforamation and populate them
into the "happy" or "Sad" spreadsheet. I don't know where I should put my
"SAD" function so that it only runs either "Happy" or "SAD". Now, I'm
getting results on both spreadsheets

bError = False
x = 15
intNumberOfTrades = 7
i = 8

Do Until bError = True

If sValue = " " Then
Exit Do
End If



'---------------------------------------------------------------------
' Check if Further Benneficiary exists (row 56A on Audsum
Mnemonic)
' if true, call HAPPY

'---------------------------------------------------------------------


c = 9
Do While (sValue < "56A" Or c < 25)

sValue = Trim$(sValue)

If sValue = "56A" Then
Call HAPPY
Exit Do
Else
c = c + 1
End If


Loop

Call SAD


i = i + 1
intNumberOfTrades = intNumberOfTrades + 1


If x < 37 Then
x = x + 2

ElseIf x = 37 Then
'go to next screen
x = 15
End If

rc = MB_CopyPSToString(gPSid, 40, 2, 5, sMessage) '

If sMessage = "I9001" Or sMessage = "E8001" Then
bError = True
End If

Loop
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
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Loop Function unable to loop Junior728 Excel Programming 1 July 28th 05 10:23 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
How do I create a For loop within a For loop? Linking to specific cells in pivot table Excel Programming 2 January 24th 05 08:05 AM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


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