+ Reply to Thread
Results 1 to 6 of 6

Formula convert to VBA

  1. #1
    Registered User
    Join Date
    05-12-2014
    Location
    bcvvb
    MS-Off Ver
    Excel 2003
    Posts
    3

    Formula convert to VBA

    Hi,

    i have formula for counting time period.

    =IF(AND(E2=TODAY();(I2=""));NOW()-F2;"")

    When i put to cell, it normally works. But i need it to insert this function via VBA and it doesn´t work. I got message "Runtime error '1004' Application or object - defined error"

    I tried this:
    Range("H2").Formula = "=IF(AND(E2=TODAY();(I2=""));NOW()-F2;"")"

    Anyone know what i am doing wrong ? Thank you for reply.

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Formula convert to VBA

    Please Login or Register  to view this content.
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Formula convert to VBA

    Try:

    Range("H2").Formula = "=IF(AND(E2=TODAY(),(I2="""")),NOW()-F2,"""")"
    Last edited by BadlySpelledBuoy; 08-25-2014 at 07:23 AM.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Formula convert to VBA

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    05-12-2014
    Location
    bcvvb
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Formula convert to VBA

    Hi,

    thank you for quick reply to all members !

    This worked for me:
    Range("H2").Formula = "=IF(AND(E2=TODAY(),(I2="""")),NOW()-F2,"""")"

    Thank you again. i was using Semicolon between function and i was missing quotes.

  6. #6
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Formula convert to VBA

    oh, the semicolon, I didn't notice that...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Convert Cell Formula to Convert Text to VBA Code
    By PY_ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-08-2014, 05:51 PM
  2. Formula as text in cell -> convert to formula result
    By AHFoddeR in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-12-2013, 02:00 AM
  3. [SOLVED] Need to Convert Formula R1C1 into A1-style but the Formula String exceeds 255 characters
    By VBA_Gary in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-04-2012, 12:09 PM
  4. Replies: 3
    Last Post: 05-18-2010, 06:14 AM
  5. [SOLVED] how to convert a formula into text in order to display the formula
    By Claudio Hartzstein in forum Excel General
    Replies: 2
    Last Post: 07-13-2006, 05:05 AM

Tags for this Thread

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