Consulting

Results 1 to 7 of 7

Thread: Sleeper: Sub & Function

  1. #1

    Sleeper: Sub & Function

    Hello All,

    I created a function refering to different spreadsheets (so far nothing exceptional).

    On one of the sheets, I created a dropdown menu (control), linked to a cell.

    When I do change the dropdown, then the function referring to it adjusts only one time after editing VBA (VBA editor).
    After that, any change on the dropdown won't affect the function (though the cell to which it refers is updated)...

    What I mean by VBA editing, is just adding a comment anywhere (not specifically related to the function)

    Any idea??? I tried a sub on_change () calculate =>Same result...

    Thanks all for your help...

  2. #2
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    Can you tell in more details.
    Is what you mean in Sheet is Combo Box?


    Sorry, I can't get what you say.
    Thanks.

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by greatheavy
    Hello All,

    I created a function refering to different spreadsheets (so far nothing exceptional).

    On one of the sheets, I created a dropdown menu (control), linked to a cell.

    When I do change the dropdown, then the function referring to it adjusts only one time after editing VBA (VBA editor).
    After that, any change on the dropdown won't affect the function (though the cell to which it refers is updated)...

    What I mean by VBA editing, is just adding a comment anywhere (not specifically related to the function)

    Any idea??? I tried a sub on_change () calculate =>Same result...

    Thanks all for your help...
    Are you using Excel 97?

  4. #4
    Yes it is a combo Box, on one of the sheets (let call it sheet "X").
    The function is on a Modul
    The function applies on the same sheet "X":
    It tests the value of the cell linked to the combo box (still on the "X" sheet)
    It refers to a value on column A of the "X" sheet.

    Then it goes to a "Y" sheet, and while the first column of this "Y" Sheet is not empty, it returns the value corresponding to the value on column A (Ok, sorry for the unclear explanation... It is basically a Vlookup referring to different fields).

    Does that make it any clearer? THanks again.

  5. #5
    My concern, is that normally, any function would update when you modify the content of a cell...

    ex,
    function test(a)
    test = a*2
    end function

    if cell A1 =4 test(A1)=8 => If I modify A1, then Test adjusts, correct?
    Well in my case, let say I change the A1 cell, and the function doesn't recalculate...

  6. #6
    Nope, I'm using XL 2003

  7. #7
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Put this at the start of your function.

    Application.Volatile

    Also maybe you can post an attachment that will help us take a closer look.

Posting Permissions

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