+ Reply to Thread
Results 1 to 4 of 4

VBA Loop for averaging multiple cells adjacent to date criteria column

  1. #1
    Registered User
    Join Date
    12-28-2012
    Location
    Madison, WI
    MS-Off Ver
    Excel 2007
    Posts
    3

    VBA Loop for averaging multiple cells adjacent to date criteria column

    Hello all, I'm brand new to this forum so please bear with me. My background in programming is not strong, VBA is the only language I have any experience in and it's minimal at best. I usually utilize excel in the worksheet formula manner but have just recently started expanding into simple VBA programs. I find myself severely lacking in technical language and (obviously) familiarity. I purchased a book and it has helped some but i'm not getting the wealth of language examples I feel that I need. What I'm looking for in this post is help figuring out how to write it, not just completed written programs yet. Thank you in advance for any help you can give.

    Abstract:
    Part of my work is tracking/analyzing results from water samples of 2 systems, 3 tests each. Current program has userform for entering data and populating entries chronologically into a spreadsheet. One of my duties requires reporting Fiscal year quarterly averages of these results. I have created a user form that will take input fiscal years, and allow me to check boxes (4 per year input, one for each quarter) which will eventually determine how many times this code segment is used, for which date ranges it will be used for, and for which cells will be populated in the reporting worksheet.

    Requirements:
    This code will run when a checkbox=True. It will cycle down a column of dates, checking each cell against a conditional date range. For those dates that satisfy the first condition it will advance and check against a second condition. If the second condition is satisfied it should advance a counter variable by 1, and increase two different variables by the sum of the indicated adjacent row cells. Once this is complete is should advance to the next row and repeat process until second condition=False. At this point it should output the value of both variables divided by i respectively to another worksheet cell location. See flowchart for further clarification:

    VBA_Project_Flow_Chart.jpg
    date conditions shown are examples, actual conditions will be declared for each checkbox prior to code

    Where would you start? What type of Function/Loop/etc would you use? How would you ensure it only cycled through your "Date" column while looking for True/False conditions? Once again, thank you for your help.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: VBA Loop for averaging multiple cells adjacent to date criteria column

    Hello Swampy79,

    Welcome to the Forum!

    While programming is fundamentally a scientific discipline, it is also an art form. The artistic aspect is realized in the GUI allowing function to follow form. It would help to see the workbook data and its layout along side with some perspective arrangements of the final form.

    To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.

    File Manger Pic
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-28-2012
    Location
    Madison, WI
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA Loop for averaging multiple cells adjacent to date criteria column

    I have attached a sample of version of what I have completed so far, Sheet 1 is where all my command buttons are located for calling the userforms, sheet 2 is the database, and sheet 3 is the report worksheet. Thanks for any help you can give me.



    SampleLog.xlsm

  4. #4
    Registered User
    Join Date
    12-28-2012
    Location
    Madison, WI
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA Loop for averaging multiple cells adjacent to date criteria column

    Bump for help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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