+ Reply to Thread
Results 1 to 3 of 3

Cannot get macro to paste a formula in specific cells

  1. #1
    Registered User
    Join Date
    11-03-2013
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    4

    Cannot get macro to paste a formula in specific cells

    I'm trying to write a code to place a formula into specific cells based on user input. If I write "= 1" or some other specific value then it pastes into the proper cells no problem but when I ask it to place a formula into those cells I keep getting compile errors. The formula works if I manually place it into the cells so it must be a VBA syntax issue.

    For x = 2 To y

    cells(x, 1) = "=MATCH(INDIRECT("b"&(ROW()))&"*",MSLD!A:A,0)"

    I've double checked that I've closed all parenthesis and quotes a million times. If it helps, when I close the error message it highlights the "b" which I assume is telling me that's where my error lies.

    Thanks in advance!

    Brian

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Cannot get macro to paste a formula in specific cells

    = "=MATCH(INDIRECT(""b""&(ROW()))&"" * "",MSLD!A:A,0)"
    mind you shouldnt it be
    = "=MATCH(INDIRECT(""b""&ROW())&""*"",msld!A:A,0)" or do you really want a space either side of *
    Last edited by martindwilson; 11-03-2013 at 09:58 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    11-03-2013
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Cannot get macro to paste a formula in specific cells

    Yes! that worked. thank you. i guess that makes sense, it doesn't know that the beginning quote isn't the end of the previous quote so you have to start and stop every quote before you can start another? i think i get it now, thanks again.

+ 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. Replies: 4
    Last Post: 10-31-2012, 08:06 PM
  2. Macro - Copy Specific Cells in 1 workbook and paste in another.
    By liybpg in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-23-2012, 10:55 AM
  3. [SOLVED] Macro to sort and paste data in specific cells
    By planbms in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-12-2012, 07:39 PM
  4. [SOLVED] Macro Copy Paste specific cells
    By guydixon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2012, 01:16 AM
  5. Copy and Paste Special Values Macro ignoring cells with specific condition
    By chendriks47 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-06-2011, 03:01 AM

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