+ Reply to Thread
Results 1 to 3 of 3

VBA button to generate numbers based on formula

  1. #1
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    VBA button to generate numbers based on formula

    Hi there,

    Is this possible with VBA? Please see the attached.

    I would like to first select a period and then hit that button to generate numbers in the green highlighted cells.( I have highlighted them for you to see easily) Also, I have left the formula in the formula bar for you to see. (these are formula I have been using in standard formula bar). You may notice that I am essentially using the period as a filter in the formula argument.

    So I'm trying to have those formula built in the VBA backend. When the button is clicked, Excel will populate the table based on formula used.

    Is this possible at all?

    Thank you
    Attached Files Attached Files

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: VBA button to generate numbers based on formula

    Why do you want VBa to do this? What's wrong with your formulae? They all seem to work, to me at least.

    Try this workbook to see if it does as you want.

    The idea is to build your formula into strings and use these to calculate your conditions.
    I'm restricted to 2003 at the moment so I have used SUMPRODUCT() instead of COUNTIFS() in this trial workbook.

    I've tried to replicate your workbook for testing, it would be useful to have sheets "VGH ED" and "VGH Clinic Intake" with sensitive data disguised/removed.

    The code is a first attempt and doubtless could be improved, it isn't linked to a button.

    Make some changes in the dummy worksheets then select from the dropdown in Sheet "Analysis VBA" D3 to trigger the code.
    If you have say "P 5" selected and make further changes then you'll have to Select it again to update the worksheet.

    This is at best a temporary solution.
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: VBA button to generate numbers based on formula

    Thank you Marcol.

    I have taken another approach on this and is in testing mode. I will repost it should I have any questions.

    Thank you for your help anyhow.

+ 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