+ Reply to Thread
Results 1 to 4 of 4

Using "text" in activecell.formula

  1. #1
    Forum Contributor
    Join Date
    09-28-2006
    Posts
    122

    Using "text" in activecell.formula

    Hi all

    I am trying to enter formula's into 5 cells on my worksheet,
    I have the following code in a macro, 4 lines work and 1 does not
    (VBA will not allow the red line - its error is "expected end of statement" and the blue portion is highlighted)

    Dim Rownum
    Rownum = 6

    ActiveSheet.Range(Cells(Rownum, 35).Address).Formula = "=ROUND( IF(AM4>0,0,IF(AM5=0,AN4,SUM(AN4:OFFSET(AN4,AM5,0) ))),2)"

    ActiveSheet.Range(Cells(Rownum, 39).Address).formula ="=IF(B4="s",AM5+1,0))"

    ActiveSheet.Range(Cells(Rownum, 42).Address).Formula = "=ROUND( IF(AM4>0,0,IF(AM5=0,AN4,SUM(AN4:OFFSET(AN4,AM5,0) ))),2)"

    ActiveSheet.Range(Cells(Rownum, 43).Address).Formula = "=IF(O4>0,GCNPcosts*O4,0)"

    ActiveSheet.Range(Cells(Rownum, 44).Address).Formula = "=ROUND( IF(AM4>0,0,IF(AM5=0,AQ4,SUM(AQ4:OFFSET(AQ4,AM5,0) ))),2)"
    anybody have any clue what do i need to do to get this line of code to operate
    thanks for the help

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Put doubled the quote marks that you want as part of the string, as in
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    09-28-2006
    Posts
    122
    thanks mike, tried that code but it didnt work

    vba accepted it ok but when the macro ran it gave an error on that line of code

    run time error 1004
    application-defined or objec-defined error

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    There is an extra right parenthesis inside the quotations marks.

+ 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