+ Reply to Thread
Results 1 to 3 of 3

Problems with VBA code to paste formula in cell

  1. #1
    Forum Contributor
    Join Date
    02-09-2004
    Location
    Cardiff - Wales - UK
    MS-Off Ver
    2013
    Posts
    475

    Question Problems with VBA code to paste formula in cell

    Hi,

    I’m trying to use a macro to paste the following formula (kindly supplied by Alkey in a previous post) i.e.

    Please Login or Register  to view this content.
    =SUMPRODUCT(--(P2:P1000="Met"),SUBTOTAL(103,OFFSET(P2:P1000,ROW(P2:P1000)-MIN(ROW(P2:P1000)),0,1)))
    Please Login or Register  to view this content.


    into a cell ’V1’ but I keep getting the error message :-

    Compile error
    Expected: end of statement

    The syntax I am using is :-

    Please Login or Register  to view this content.
    Range("V1").Formula = "=SUMPRODUCT(--(P2:P1000="Met"),SUBTOTAL(103,OFFSET(P2:P1000,ROW(P2:P1000)-MIN(ROW(P2:P1000)),0,1)))"
    Please Login or Register  to view this content.
    Any assistance would be greatly revived

    Many thanks in advance

    Regards

    rob
    Rob

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,522

    Re: Problems with VBA code to paste formula in cell

    You need to double the double quotes within a formula string.
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-09-2004
    Location
    Cardiff - Wales - UK
    MS-Off Ver
    2013
    Posts
    475

    Re: Problems with VBA code to paste formula in cell

    Jindon

    EXCELLENT,

    many thanks


    Regards


    Rob

+ 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. [SOLVED] Problems finding the next empty cell and paste value
    By moosmahna in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-17-2017, 08:47 AM
  2. [SOLVED] Paste problems with VBA code
    By chris01252 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-15-2015, 12:31 PM
  3. Replies: 2
    Last Post: 06-25-2014, 01:55 AM
  4. [SOLVED] want to edit recorded macro code or copy a cell with formula and paste it down to "x" cell
    By bmbalamurali in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 10-25-2013, 04:57 PM
  5. Replies: 1
    Last Post: 04-15-2013, 08:06 AM
  6. Problems with Copy/Paste Code
    By ChemistB in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-27-2008, 09:20 AM
  7. Paste by rows and blank cell problems
    By mr starface in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-16-2006, 02:15 PM

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