+ Reply to Thread
Results 1 to 5 of 5

Multi-conditional Do While loop in conjunction with a multi-conditional Do Until Loop

  1. #1
    Registered User
    Join Date
    11-28-2020
    Location
    Socal
    MS-Off Ver
    10
    Posts
    7

    Multi-conditional Do While loop in conjunction with a multi-conditional Do Until Loop

    -
    I'm wanting to build a function that has multiple conditions for both Do While/Until Loops

    Sub Macro
    Dim i as integer

    C1: cell.value(1,3)
    C2: cell.value(2,3)
    C3: cell.value(3,3)

    D1: cell.value(1,4)
    D2: cell.value(2,4)
    D3: cell.value(3,4)


    Do While IF C1<C2 AND C2>C3

    Do Until D1>D2 AND D2<D3

    The Return statement will be "Dx - Cy"

    "Dx" will be D3 (pertaining to the Do WHILE condition)

    "Cy" will be C3 (pertaining to the Do Until condition).

    What would be the best way to go about this? Still new to excel vba and its been fun to say the least.
    Last edited by FDibbins; 12-07-2020 at 12:56 AM.

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Multi-conditional Do While loop in conjunction with a multi-conditional Do Until Loop

    hmmmmmmm....the description is tough to follow, really. here's what I personally see as your wish:

    - you want to run 2 loops.
    - you want to check if 1 cells is less than / greater than another in every iteration of the loop.
    - you want 2 types of loops - DO WHILE and DO UNTIL.

    that right? if so, you can make it much simpler than that. furthermore, there is no return statement in this language. that is for more advance langs like web languages. functions can return, subs cannot. but ""return"" is not used. a simple assignment to the function's name via an equals (=) sign is.

    regarding Dx and Cy, not really sure what you're talking about there. got details?

  3. #3
    Registered User
    Join Date
    11-28-2020
    Location
    Socal
    MS-Off Ver
    10
    Posts
    7

    Re: Multi-conditional Do While loop in conjunction with a multi-conditional Do Until Loop

    Quote Originally Posted by vba_php View Post
    hmmmmmmm....the description is tough to follow, really. here's what I personally see as your wish:

    - you want to run 2 loops.
    - you want to check if 1 cells is less than / greater than another in every iteration of the loop.
    - you want 2 types of loops - DO WHILE and DO UNTIL.

    that right? if so, you can make it much simpler than that. furthermore, there is no return statement in this language. that is for more advance langs like web languages. functions can return, subs cannot. but ""return"" is not used. a simple assignment to the function's name via an equals (=) sign is.

    regarding Dx and Cy, not really sure what you're talking about there. got details?
    Yes, I want to run two loops, but I'm wanting to treat the "Do While" Loop as the beginning of a trend. The "Do Until" loop will be treated as the end of a trend. I understand it's a bit difficult to follow. Currently on my personal laptop and don't have my access to my spreadsheets.

  4. #4
    Registered User
    Join Date
    11-28-2020
    Location
    Socal
    MS-Off Ver
    10
    Posts
    7

    Re: Multi-conditional Do While loop in conjunction with a multi-conditional Do Until Loop

    Okay so here's the spreadsheet I'm referring to the "trend" is when a peak forms within numbers in column B. Think of it as an upside down letter "V". This would be the "beginning" of the trend. The end of the trend is when the numbers in column C form a letter "V". The return statement is basically the difference between the last day of the beginning of this trend and the last day of the end of trend. I know this is confusing, so if I need to elaborate a little more, please let me know.
    Last edited by RavaginRadish; 12-06-2020 at 05:36 PM.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Multi-conditional Do While loop in conjunction with a multi-conditional Do Until Loop

    RavaginRadish please do NOT delete post after they have been made, that is not how we do things around here
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Why am I receiving an error message with this multi-variable FOR loop?
    By Ulnarian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2019, 11:17 AM
  2. Writing the loop for updating multi-table MS access file using multi-sheet excel
    By relabz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-29-2016, 03:10 PM
  3. [SOLVED] Populating Multi-Column Listbox using For Next Loop
    By ykobure in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-30-2015, 03:31 AM
  4. [SOLVED] Multi Macro Loop Through sheets
    By jrembold in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2015, 04:10 PM
  5. [SOLVED] Multi-Conditional Conditional Formatting and Dates
    By Mousiefuzz in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-07-2015, 04:09 AM
  6. [SOLVED] *Multi for Array loop
    By aka 42 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2014, 04:43 AM
  7. Do..Loop in multi sheets
    By norika in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-26-2005, 04:58 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1