+ Reply to Thread
Results 1 to 7 of 7

Drop Down forces calculate

  1. #1
    Registered User
    Join Date
    08-27-2007
    Posts
    22

    Drop Down forces calculate

    I am using a spreadsheet with a user defined function that contains an if and case statements fromthis thread. I am using a combo box to change the dependent cells but need something to automatically calculate the sheet. is there a way I can have a calculation occur every time a selection is made in the combo box or is there a macro that will do it. I'm fairly new to VBA so some direction with the solution would be greatly appreciated

    thanks
    Attached Files Attached Files
    Last edited by demuro1; 10-12-2008 at 03:41 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    How about

    Please Login or Register  to view this content.
    But why are you having to calculate at all? Have you turned Automatic calc off?

  3. #3
    Registered User
    Join Date
    08-27-2007
    Posts
    22
    no I have automatic calculate on but for some reason it's not doing it. not only that but when I click calc now it doesn't calculate either. Give it a try in the spreadsheet.

    how would I implement your suggested code?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Quote Originally Posted by demuro1 View Post
    no I have automatic calculate on but for some reason it's not doing it. not only that but when I click calc now it doesn't calculate either. Give it a try in the spreadsheet.

    how would I implement your suggested code?
    Hi,

    I'd missed the point that you were using a UDF - which often causes problems for the reasons that are very well explained in the link below.

    You can use the

    Please Login or Register  to view this content.
    instruction at the top of your UDF code, but please note the downsides explained in the link.

    The other thing you could do to avoid the potential problems with using the Application.Volatile is to force a recalculation by copying and pasting one of your cells.

    e.g.

    Please Login or Register  to view this content.

    http://www.decisionmodels.com/calcsecretsj.htm
    HTH

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Your function adjust takes values from A16 and A29 directly, not as arguments. Thus changeing the values in those cells doesn't trigger a Calculation. Plus, it makes editing the spreadsheet (eg. adding a row) more difficult. If you pass those as an argumnent to your UDF, it will calculate when their values are changed.
    The formula =adjust(C11) becomes =adjustMark2(C11,$A$16,$A$29)
    Please Login or Register  to view this content.
    Last edited by mikerickson; 10-12-2008 at 03:17 PM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Registered User
    Join Date
    08-27-2007
    Posts
    22
    Quote Originally Posted by mikerickson View Post
    Your function adjust takes values from A16 and A29 directly, not as arguments. Thus changeing the values in those cells doesn't trigger a Calculation. Plus, it makes editing the spreadsheet (eg. adding a row) more difficult. If you pass those as an argumnent to your UDF, it will calculate when their values are changed.
    The formula =adjust(C11) becomes =adjustMark2(C11,$A$16,$A$29)
    it works perfectly except that when $a$16=2 and $a$29= anything but 1 it returns zero "0"

    any suggestions. other than that it's perfect

    thanks so much everyone





    I fixed it I just added one more elseif statement for the given condition. Man you guys are so awesome thanks so much for the help
    Last edited by demuro1; 10-12-2008 at 03:40 PM. Reason: answered my own question

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    I noticed that behaviour, its the same behaviour as the function Adjust.
    Just as each of the Select Cases has a Case Else, the If...ElseIF...ElseIf...End If needs an final Else clause to deal with the unspecified situations.

+ 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. Select in Drop down box to a different drop down box
    By syerbic in forum Excel General
    Replies: 8
    Last Post: 04-09-2012, 11:56 AM
  2. Cell drop down and If formulas
    By Alsebiates in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 11-02-2007, 05:15 PM
  3. File fails to calculate - corrupted?
    By bahguy in forum Excel General
    Replies: 3
    Last Post: 08-09-2007, 03:53 AM
  4. drop down boxes, etc.
    By jammanex in forum Excel General
    Replies: 1
    Last Post: 04-13-2007, 04:33 PM
  5. From one drop down to another
    By derwood in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-09-2007, 06:36 PM

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