Results 1 to 13 of 13

Thread: Probably dead obvious...

  1. #1

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Probably dead obvious...

    Why don't spreadsheet cells that call VBA functions automatically update themselves when you change other cells?

    Is there any way to overcome this?

    I have autocalculate switched on and my macros are enabled, whats stopping the (public) function (in a module) from being called?

    I know the function works because if I double click it and immediately hit enter, it updates to the correct value.
    I don't live here any more.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Probably dead obvious...

    MS Excel??

    How are you calling the sub?
    Are you using WorkBook_SheetChange?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Probably dead obvious...

    Excel yeah.

    I call the func like this:
    "=CollateAndCalcShare()"
    (in the cell directly)

    Not using sheetchange.

    Any ideas ?
    I don't live here any more.

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Probably dead obvious...

    Um...

    Nope no idea. Tried putting that function (which returns "Test") and it didn't run. Just got the #Name?

    I take it the function when run in the VBA window works fine. But the function doesn't run from the spreadsheet. And it doesn't error. No idea . quirk of MS Excel...

    Which version are you running (being curious) ?

    EDIT:
    Version Excel 2000 here...
    Shoved the code into a module (not the ThisSheet module) and it works fine.
    Is it something in your code? (not likely) or perhaps a re-install of excel is required.
    Tested with this code:
    Code:
    Public Function CollateAndCalcShare() As String
        CollateAndCalcShare = "Test" & Cells(2, 3)
    End Function
    The function is in cells(2,2) (B2)
    Last edited by Ecniv; Feb 28th, 2005 at 11:06 AM.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  5. #5

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Probably dead obvious...

    Excel v9.0.4402 SR1

    I know the function definitely does work. It's just that excel won't call it. I've tried everything from adding 0 to the result to try to jog it into action and even linking another cell after the calling cell to fetch the data from it but nothing happens.
    I don't live here any more.

  6. #6
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Probably dead obvious...

    Does the function I posted earlier work?
    I have the same version excel here at work so I could run a test to see whether its a crap install?
    Post the code or a zip file? (if it doesn't breech data protection stuff)

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  7. #7

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Probably dead obvious...

    The cell in question is marked "Contractor Share", I want it to update itself when "Actual Cost" is altered.

    This is really annoying.
    Attached Files Attached Files
    I don't live here any more.

  8. #8
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Probably dead obvious...

    I don't think you are gonna like this...
    but...
    Code:
    CollateAndCalcShare = CDbl(CStr(CalculateShare(Range("B18").value, Range("B22").value, b)))
    Replace that line... The bit in bold was the part I added. Seems to run then. Debug fine without it but doesn't like it except on the entering first time unless that is in there, then works fine (cstr? cdbl? your output of the function is double...)



    Hope that fixes it

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  9. #9

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Probably dead obvious...

    I tried what you said but it made no difference at all.

    I took out both cdbl and cstr because they appear to be redundant. Still doesn't work though.

    VBA/Ofice are the worst things ever. *HATE*
    I don't live here any more.

  10. #10
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Probably dead obvious...

    Word/excel vba is crap against access vba (seems more polished)
    Access vba is different and probably worse than vb
    vb is worse compared to vb.net

    I checked the help files and there is no mention of using custom macros in cells as functions. Which means you may need to put it in the worksheet change to get it to run.

    Sorry. Excel is pants. How come you didn't use a vb.net project for this? its pretty simple isn't it??
    Attached Files Attached Files
    Last edited by Ecniv; Mar 1st, 2005 at 07:38 AM.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  11. #11

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Probably dead obvious...

    Quote Originally Posted by Ecniv
    Sorry. Excel is pants. How come you didn't use a vb.net project for this? its pretty simple isn't it??
    Funny you should say that. I actually did the initial prototype in VB.net just so I could get the stupid algorithm right (which was invented by a typically stupid accountant).

    However, the people that are intended to use this system do not have the framework on their machines. So it falls to excel.
    Attached Images Attached Images  
    Last edited by wossname; Mar 1st, 2005 at 07:46 AM.
    I don't live here any more.

  12. #12

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Probably dead obvious...

    Sorted it out now. Bunged the call into the calculate event instead.

    Cheers for the help.
    I don't live here any more.

  13. #13
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Probably dead obvious...

    lol (sigh)
    Attached a zip file to my last post.. take a look and see what you think?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

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



Click Here to Expand Forum to Full Width