+ Reply to Thread
Results 1 to 15 of 15

My VBA creates an error in a formula

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-09-2009
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007
    Posts
    128

    My VBA creates an error in a formula

    Hi,

    I've got an Excel workbook, with a built in macro that runs when you choose an entry in the two combo boxes.

    IF you then try to change the value in B9:B15 or B22:B25 then an error message pops up and says that the sheet contains a formula with an error.

    If you do not change both the combo boxes, then no such error shows up.

    I've looked through formulas etc, but I can't seem to find the error. I hope that some of you might be able to give a guiding hand.

    See attached file
    Attached Files Attached Files
    Last edited by ChrisNor; 05-14-2009 at 05:10 AM. Reason: Solved

  2. #2
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186

    Re: My VBA creates an error in a formula

    Hi ChrisNor,
    I tested it, but no error msg appears. Could not replicate it.

  3. #3
    Forum Contributor
    Join Date
    03-09-2009
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: My VBA creates an error in a formula

    That is strange I've tested it on 3 different machines here, and all get the same error.

    1. Pick something from the first combie box. (drop-down list)
    2. Then pick something from the second drop-down list
    3. When you have done this try to change the value in cell B12

    Now you should get an error saying that one of the formulas contains a reference to a range that do not exist, or something. (this error message do not come when doing this before you have chosen from BOTH the drop-down lists)

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: My VBA creates an error in a formula

    Your formula in H2 is returning a #REF as the row references is outside the array you are indexing in.

    ="<-- Systemvirkningsgrad "&INDEX('B.8 - Årsvirk.gr. oppvarming'!B4:B19,TEK!C2,0)

    TEK!C2 contains 18 but the table only has 16 rows.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Forum Contributor
    Join Date
    03-09-2009
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: My VBA creates an error in a formula

    Even if I delete the formula in H2, I still get the error

  6. #6
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186

    Re: My VBA creates an error in a formula

    I did it and still no error.
    Each time I change a value in column B (after selecting different options in both comboBox) the piechart changes nicely. Even if i write a text inside the value fields there appears no error msg.

    I first thought it might be a problem in the decimal separator on your system, but I changed that option from Point (.) to Comma(,) and in both cases worked fine.

    Sorry.

    P.D. I'm using Excel 2003 to test.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: My VBA creates an error in a formula

    I think this is a xl2007 issue/bug.

    When your code cuts and paste some of the cells the contents of the chart is destroyed. At this point the chart contains Ref problems. Simply pointing the source data at the range again is not removing the problem.

  8. #8
    Forum Contributor
    Join Date
    10-16-2008
    Location
    Iowa
    Posts
    121

    Re: My VBA creates an error in a formula

    The formula in B7 is
    =INDEX('Effekt og Energibehov'!$B$36:$N$36,0,$D$2)
    This points to a different worksheet.

  9. #9
    Forum Contributor
    Join Date
    03-09-2009
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: My VBA creates an error in a formula

    Quote Originally Posted by mhuston View Post
    The formula in B7 is
    =INDEX('Effekt og Energibehov'!$B$36:$N$36,0,$D$2)
    This points to a different worksheet.
    Yes this is a one of the 3 hidden sheets in the workbook.. I don't see anything wrong with the formula though

  10. #10
    Forum Contributor
    Join Date
    03-09-2009
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: My VBA creates an error in a formula

    That simple...


    Great thanks...

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: My VBA creates an error in a formula

    I need to post an amendment to this as I stated something that was incorrect.

    The CUT+PASTE destruction of the chart links is NOT a xl2007 bug.
    This behaviour exists in previous versions, tested on xl2000.

+ 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