Results 1 to 4 of 4

pasting formula in a cell for a macro

Threaded View

  1. #1
    Registered User
    Join Date
    05-06-2014
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    2

    pasting formula in a cell for a macro

    While using a macro, I am trying to paste the following formula into cell J2:

    =IF(B2="258801",VLOOKUP(G2,Matrix!A:L,4,FALSE),IF(B2="258701",VLOOKUP(G2,Matrix!A:L,5,FALSE),IF(B2="258601",VLOOKUP(G2,Matrix!A:L,5,FALSE),IF(B2="258501",VLOOKUP(G2,Matrix!A:L,6,FALSE),IF(B2="258101",VLOOKUP(G2,Matrix!A:L,7,FALSE),IF(B2="252201",VLOOKUP(G2,Matrix!A:L,8,FALSE),IF(B2="258301",VLOOKUP(G2,Matrix!A:L,9,FALSE),"")))))))&IF(B2="258401",VLOOKUP(G2,Matrix!A:L,10,FALSE),IF(B2="258401",VLOOKUP(G2,Matrix!A:L,10,FALSE),""))

    When I begin recording my macro, even if that is the only thing I do, I still get an error when I try to begin recording, select the cell, click in to edit it, paste my fomula, and then stop recording.

    The error is as follows:

    Sub Macro4()
    '
    ' Macro4 Macro
    '
    
    '
        ActiveCell.FormulaR1C1 = _
            "=IF(RC[-8]=""258801"",VLOOKUP(RC[-3],Matrix!C[-9]:C[2],4,FALSE),IF(RC[-8]=""258701"",VLOOKUP(RC[-3],Matrix!C[-9]:C[2],5,FALSE),IF(RC[-8]=""258601"",VLOOKUP(RC[-3],Matrix!C[-9]:C[2],5,FALSE),IF(RC[-8]=""258501"",VLOOKUP(RC[-3],Matrix!C[-9]:C[2],6,FALSE),IF(RC[-8]=""258101"",VLOOKUP(RC[-3],Matrix!C[-9]:C[2],7,FALSE),IF(RC[-8]=""252201"",VLOOKUP(RC[-3],Matrix!C[-9]:C[2" & _
            "E),IF(RC[-8]=""258301"",VLOOKUP(RC[-3],Matrix!C[-9]:C[2],9,FALSE),"""")))))))&IF(RC[-8]=""258401"",VLOOKUP(RC[-3],Matrix!C[-9]:C[2],10,FALSE),IF(RC[-8]=""258401"",VLOOKUP(RC[-3],Matrix!C[-9]:C[2],10,FALSE),""""))"
        Range("J3").Select
    End Sub

    Can anyone help? Thank yoU!
    Last edited by arlu1201; 05-08-2014 at 10:01 AM. Reason: Use code tags.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro Help with Pasting Formula Values
    By carden2 in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 09-21-2012, 05:29 PM
  2. [SOLVED] Pasting Formula with Macro
    By L2012 in forum Excel General
    Replies: 2
    Last Post: 09-17-2012, 12:45 PM
  3. [SOLVED] Pasting a certain formula in a cell using a macro
    By nenadmail in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-07-2012, 12:02 PM
  4. Pasting a Formula in a Macro
    By Alexander_Read in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-19-2008, 10:49 AM
  5. Pasting a value not a formula in a macro
    By Alec H in forum Excel General
    Replies: 1
    Last Post: 02-23-2006, 07:00 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