+ Reply to Thread
Results 1 to 2 of 2

macro for index, match

  1. #1
    Registered User
    Join Date
    08-16-2010
    Location
    us
    MS-Off Ver
    Excel 2007
    Posts
    21

    Question macro for index, match

    I am having trouble adding in an index, match formula to my existing macro.

    Here is the macro I am trying to add it to:
    Sub AllElementsListEdit()

    'select sheet
    Sheets("All Elements List").Select
    'change text to number
    Cells.SpecialCells(xlCellTypeLastCell) _
    .Offset(1, 1).Copy
    ' Range("a:a") is what will be changed from text to a number
    Range("a:a").PasteSpecial Paste:=xlPasteValues, _
    Operation:=xlPasteSpecialOperationAdd
    With Selection
    .VerticalAlignment = xlTop
    .WrapText = False
    End With
    Selection.EntireColumn.AutoFit
    'filtering part
    'Assign the value in A2 to a variable
    Criteria = Worksheets("Numeric Response Report").Range("A2").Value

    With Worksheets("All Elements List").UsedRange

    'Filter Column A for the defined criteria
    .AutoFilter field:=1, Criteria1:=Criteria

    'index, match formula, not working

    End With

    End Sub

    and here is my index, match macro:
    Sub Macro1()
    ActiveCell.FormulaR1C1 = _
    "=INDEX('All Elements List'!C[3],MATCH('Numeric Response Report'!C[2],'All Elements List'!C[8],0))"
    Range("C2").Select
    End Sub

    I know the main problem is the ActiveCell. part, but I don't know how to change it. Plus I had to record it becuase I don't know how to write the vba for the formula.
    What I want to achieve in the index match is:
    1) look at column E in the "numeric reponse report" worksheet

    2) go to the "all elements list" worksheet. in column K that same value will be found

    3) to bring back the value in column F

    Any help would be greatly appreciated!!!

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: macro for index, match

    Hi psrs0810
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

+ 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