+ Reply to Thread
Results 1 to 6 of 6

VBA wave plan builder

  1. #1
    Forum Contributor
    Join Date
    09-21-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    131

    VBA wave plan builder

    Hello all,

    I have got this little puzzle for myself that i cant crack. Given snapshot below shows input and desired output at the bottom. Script is supposed to build a wave plan based on the input and a setting in the middle which determined how big a single wave should be.

    Input at the top determines the order of each DSP per pad. Script should follow this logic: if first dsp in the pad has got more then 24 routes make first wave of 24 routes and whats above push it to second wave. If DSP does not have enough routes to fill whe whole wave of 24 drivers then bring some of the drivers that are second in order on the pad. Hope the logic is clear.

    I was thinking of if conditions inside the loop but realized that this would require hard coding every single situation. I believe this could be done in much more efficient way.

    Any suggestions, ideas?

    wave_plan.PNG
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,692

    Re: VBA wave plan builder

    Maybe :
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    09-21-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    131

    Re: VBA wave plan builder

    You are a genius! Now I just need to understand how you did this.

    Could you explain why you are diming variable separately rather than all in one go like this:?
    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,692

    Re: VBA wave plan builder

    Thanks for marking the thread as solved and rep.points.

    In VBA (and other VB families like VB6), we must define each variable name immediately followed by it's type (unlike other programming language like C++ which you can define all the variables at once for one variable type).

    So, if you do it like this :
    Please Login or Register  to view this content.
    it means you define a as variant, b as variant, i as variant, p as variant, w as variant, t as variant, u as variant; only wsize that defined as long.

  5. #5
    Forum Contributor
    Join Date
    09-21-2016
    Location
    UK
    MS-Off Ver
    2016
    Posts
    131

    Re: VBA wave plan builder

    Ahhh... I see what you mean, thank you for explaining.

    Would you be able to go through the code and explain me a little bit what is happening on each line?

  6. #6
    Forum Guru
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,692

    Re: VBA wave plan builder

    Ok, I'll try.

    >> Get the wavesize
    Please Login or Register  to view this content.
    >> Get input array a
    Please Login or Register  to view this content.
    >> Create output array b where the result will be written
    Please Login or Register  to view this content.
    >> Looping for each row in input array
    Please Login or Register  to view this content.
    >> w is variable to hold current wave number (as seen on B21:B32) like Wave 1, Wave 2, etc
    >> t is variable to hold carried total, for example on D4, the route is 26, so first time t=26
    >> after subtracted by wavesize it becomes t=2, after added by D5 (route is 13) it becomes t=15, etc
    >> Now on column 2, anytime we get the value of a row is different with the value of row above it,
    >> (like Orange vs Blue) we will reset the w to 1 and t to 0
    Please Login or Register  to view this content.
    >> It is possible that one data row is splitted to several output rows (like D4), so we must
    >> process this inside another loop (Do..Loop)
    Please Login or Register  to view this content.
    >> Write output to Excel range
    Please Login or Register  to view this content.

+ 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. Square Wave Averages
    By reehilch in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-14-2014, 10:56 AM
  2. Replies: 0
    Last Post: 03-26-2014, 05:23 AM
  3. MLM matrix plan plan 4x4 coding/formula
    By ncsvapi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-03-2013, 08:23 AM
  4. Big Wave Hello!
    By Beanmuncher in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 03-29-2013, 11:10 PM
  5. Replies: 10
    Last Post: 05-11-2012, 02:14 AM
  6. [SOLVED] sine wave trendline
    By Amedee Van Gasse in forum Excel General
    Replies: 10
    Last Post: 07-12-2005, 11:05 AM
  7. [SOLVED] sine wave trendline
    By dumb_founded in forum Excel General
    Replies: 3
    Last Post: 04-11-2005, 08:07 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