+ Reply to Thread
Results 1 to 11 of 11

Problem using vba code to insert a formula to certain cell

  1. #1
    Registered User
    Join Date
    10-17-2007
    Posts
    62

    Problem using vba code to insert a formula to certain cell

    Hi all,

    I have problems vith my VBA code. I try to put a formula to a certain cell using this code, but I get application defined or object defined error:

    HTML Code: 
    The weird thing is, that if I type the same formula itself to a cell, it works, so the problem shouldn't be with the formula:

    HTML Code: 
    On the other hand I tried to replace the formula in my VBA code with simpler one, like this one and that worked aswell:

    HTML Code: 
    So what am I missing here, where is the mistake?

    -Juhanen-

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Works for me if I substitute , for ; - is that definitely the separator according to your settings?

  3. #3
    Registered User
    Join Date
    10-17-2007
    Posts
    62
    Yes. ";" is the right separator for me.
    Weird that it works for you...

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Have you tried varying the active cell when you run the code? Why can't you specify the address you want?

  5. #5
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi

    Change the ; to , and it will work for you too

    Richard

  6. #6
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770
    Works here too, again having to replace ";" with "," though.

  7. #7
    Registered User
    Join Date
    10-17-2007
    Posts
    62
    Hey guys,

    Varying the active cell didn't work.
    BUT changing ; to , really did work!
    I'm amazed, because my separator really is ;

    So conclusion:

    in VBA code using ";" --> doesn't work
    in VBA code using "," --> works
    in cell formula using ";" --> works
    in cell formula using "," --> doesn't work

    I still don't get it why is that, but atleast my VBA code works now =)

    Thank you all for solving my strange problem.

    -Juhanen-

  8. #8
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Richard, do you know why that is?

  9. #9
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Stephen

    I think it is probably just an oversight by Excel's/Office's designers so that even though the system separators can be changed (ie , to ; ) they never considered - or bothered to implement - this change in the VBE and how VBA code is interpreted.

    Richard

  10. #10
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Thanks Richard. I suppose we can let them off that one.

  11. #11
    Registered User
    Join Date
    10-17-2007
    Posts
    62
    I wouldn't let them off that easily though, causes me troubles

    Btw. the reason we use ";" as a separator instead of "," here (Finland) is that we use "," for desimals. So "two point 5" is 2,5 here

    Anyways, thanks for all the help again, keep up the good work.

    -Juhanen-

+ 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