+ Reply to Thread
Results 1 to 3 of 3

Setting range to complex formula causes 1004 error

  1. #1
    Registered User
    Join Date
    07-22-2010
    Location
    Turku, Finland
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question Setting range to complex formula causes 1004 error

    I have a sub in an Excel 2003 workbook that creates a new worksheet with the click of a button. I copy a template sheet, add data from the new sheet to a sheet ("Totalt") that calculates some totals across all sheets so far, and finally add references to the latest totals on the new sheet. Everything works except for the last part.

    When the following bolded line executes I get run-time error 1004:

    Please Login or Register  to view this content.
    The strange thing is that it works if I paste the generated formula (eg. "=LOOKUP("Vecka25";Totalt!$B$7:$B$24;Totalt!$F$7:$F$24)") into the sheet manually or set the value to a dummy value like "=1+2+3". Any ideas what might cause this?

    edit: SummaryOrigin is a one-cell Range on the top left of the summary section on the new sheet (the length of the data section of the sheet varies).
    Last edited by jsoderba; 07-22-2010 at 07:12 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Setting range to complex formula causes 1004 error

    Unless you use FormulaLocal property the VBA is US centric meaning when you insert the LOOKUP formula via VBA XL will not accept it as valid given the use of Finnish delimiters ie: ; rather than ,

    If you either use:

    Please Login or Register  to view this content.
    or you convert the yearClass1AvgPrice to use US delimiters it should work without issue
    (the SUM formulae work given lack of delimiter)

  3. #3
    Registered User
    Join Date
    07-22-2010
    Location
    Turku, Finland
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Setting range to complex formula causes 1004 error

    Oh dear. I completely forgot that ";" was a localized separator. I'm so used to seeing it in the Excel view I forgot that it's different in VB.

    Thanks a lot!

+ 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