+ Reply to Thread
Results 1 to 3 of 3

VBA insert a formula into a cell

  1. #1
    Registered User
    Join Date
    10-21-2010
    Location
    Copenhagen
    MS-Off Ver
    Excel 2003
    Posts
    33

    VBA insert a formula into a cell

    I have a problem.

    I want to insert the following into a single cell using VBA:

    =if(M2<=K2;M2;0)

    I have tried:

    ActiveCell.Formula = "=IF(M2<=K2;M2;0)"

    But gets an error:

    Run-time error '1004':

    Application-defined or object-defined error
    Last edited by Freakazoid; 10-22-2010 at 01:35 AM.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: VBA insert a formula into a cell

    Try to change ';' with comma:
    ActiveCell.Formula = "=IF(M2<=K2,M2,0)"
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    10-21-2010
    Location
    Copenhagen
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: VBA insert a formula into a cell

    Quote Originally Posted by antoka05 View Post
    Try to change ';' with comma:

    Regards,
    Antonio
    It worked, Thanks alot for the help, I was stuck on this little problem, now i can go on.

+ 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