+ Reply to Thread
Results 1 to 4 of 4

Adding Formula from VBA

  1. #1
    Anders Eriksson
    Guest

    Adding Formula from VBA

    Hello!

    I want to add a formula to a cell the formula is:
    =TEXT(A1,"dddd")

    I have used this code

    formel = "=TEXT(A" & CStr(NewRow) & ";""dddd"")"
    Worksheets("Blad2").Cells(NewRow, 2).Formula = formel

    I get an error on the second line saying:
    Runtime Error '1004'
    application-defined or object-defined error

    NewRow is a valid number, e.g. 36

    What is the error?

    // Anders
    --
    English is not my first, or second, language
    so anything strange, or insulting, is due to
    the translation.
    Please correct me so I may learn better English!

  2. #2
    Dave Peterson
    Guest

    Re: Adding Formula from VBA

    What happens when you change the semicolon to a comma?

    formel = "=TEXT(A" & CStr(NewRow) & ",""dddd"")"

    Anders Eriksson wrote:
    >
    > Hello!
    >
    > I want to add a formula to a cell the formula is:
    > =TEXT(A1,"dddd")
    >
    > I have used this code
    >
    > formel = "=TEXT(A" & CStr(NewRow) & ";""dddd"")"
    > Worksheets("Blad2").Cells(NewRow, 2).Formula = formel
    >
    > I get an error on the second line saying:
    > Runtime Error '1004'
    > application-defined or object-defined error
    >
    > NewRow is a valid number, e.g. 36
    >
    > What is the error?
    >
    > // Anders
    > --
    > English is not my first, or second, language
    > so anything strange, or insulting, is due to
    > the translation.
    > Please correct me so I may learn better English!


    --

    Dave Peterson

  3. #3
    Dave Peterson
    Guest

    Re: Adding Formula from VBA

    And VBA is very USA centric.

    Even if you have the semicolon as your delimiter in your windows regional
    settings (so you see that in formulas you type), you'd still use the comma in
    your VBA code.

    Anders Eriksson wrote:
    >
    > Hello!
    >
    > I want to add a formula to a cell the formula is:
    > =TEXT(A1,"dddd")
    >
    > I have used this code
    >
    > formel = "=TEXT(A" & CStr(NewRow) & ";""dddd"")"
    > Worksheets("Blad2").Cells(NewRow, 2).Formula = formel
    >
    > I get an error on the second line saying:
    > Runtime Error '1004'
    > application-defined or object-defined error
    >
    > NewRow is a valid number, e.g. 36
    >
    > What is the error?
    >
    > // Anders
    > --
    > English is not my first, or second, language
    > so anything strange, or insulting, is due to
    > the translation.
    > Please correct me so I may learn better English!


    --

    Dave Peterson

  4. #4
    Anders Eriksson
    Guest

    Re: Adding Formula from VBA

    On Wed, 14 Jun 2006 07:18:37 -0500, Dave Peterson wrote:

    > What happens when you change the semicolon to a comma?
    >
    > formel = "=TEXT(A" & CStr(NewRow) & ",""dddd"")"
    >

    Work like a charm!

    Thank you very much! I would never have thought of this.

    // Anders
    --
    English is not my first, or second, language
    so anything strange, or insulting, is due to
    the translation.
    Please correct me so I may learn better English!

+ 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