+ Reply to Thread
Results 1 to 8 of 8

INDEX and MATCH formula in a macro

  1. #1
    Registered User
    Join Date
    02-17-2023
    Location
    Chicago Area, IL
    MS-Off Ver
    Excel 365 Desktop Version 2301
    Posts
    3

    INDEX and MATCH formula in a macro

    The formula I'm working on is a INDEX and MATCH formula with two variables and operates from data across to worksheets in the same workbook

    First question: the range is wrong and I don't know what to do to correct it.

    marco index & match.jpg


    Second question, after I fix the range, how do I make this formula work across multiple columns and rows in the sheet?

    Here's an example of the formula in Excel. I need this formula to operate in columns B-P and rows 2-60.

    formula in excel.jpg

    The reference cells need to change as the formula moves from left to right and top to bottom
    Attached Files Attached Files
    Last edited by New_To_Macros; 02-17-2023 at 12:24 PM. Reason: Adding Attachment

  2. #2
    Forum Contributor
    Join Date
    04-16-2020
    Location
    Alberta, Canada
    MS-Off Ver
    365
    Posts
    216

    Re: INDEX and MATCH formula in a macro

    If you have some sample data to post it would help. I think you should use a UDF (user defined function), not a sub.

  3. #3
    Forum Contributor
    Join Date
    04-16-2020
    Location
    Alberta, Canada
    MS-Off Ver
    365
    Posts
    216

    Re: INDEX and MATCH formula in a macro

    If your table on tab 'Zebras' is named 'Zebras'. the code would be

    Please Login or Register  to view this content.
    Why not just put the code into the cells and and statement so it's blank if there is no ID or Question?

  4. #4
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: INDEX and MATCH formula in a macro

    Hello, New_To_Macros. It is not clear what your goal is.

    Mmm... Could it be that you want to achieve the following?...

    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

  5. #5
    Registered User
    Join Date
    02-17-2023
    Location
    Chicago Area, IL
    MS-Off Ver
    Excel 365 Desktop Version 2301
    Posts
    3

    Re: INDEX and MATCH formula in a macro

    Yes, this is what I'm after...any suggestions?

  6. #6
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: INDEX and MATCH formula in a macro

    You could do something like the following:

    PHP Code: 
    Sub Macro8()
    Dim aQ&, i&, j%, R&
    Range("'Zebras'!A1").CurrentRegion
    Application.Transpose(a): UBound(a): 1
    For 2 To Q Step 2
      R 
    Ra(R1) = a(i1)
      For 
    2 To UBound(a2): a(Rj) = a(ij): Next
    Next
    With Range
    ("'Use This'!A1")
      .
    CurrentRegion.ClearContents
      
    .Resize(RUBound(a2)) = a
      
    .CurrentRegion.Columns.AutoFit
    End With
    End Sub 

  7. #7
    Registered User
    Join Date
    02-17-2023
    Location
    Chicago Area, IL
    MS-Off Ver
    Excel 365 Desktop Version 2301
    Posts
    3

    Re: INDEX and MATCH formula in a macro

    Thank you, thank you, thank you! This works beautifully

  8. #8
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: INDEX and MATCH formula in a macro

    I show you an implementation in the sheet 'Use this':
    Attached Files Attached Files

+ 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] convert index and match formula in a macro for a big dynamic spreadsheet
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-25-2017, 08:04 PM
  2. Replies: 2
    Last Post: 02-13-2016, 03:22 PM
  3. A macro to replace Index and Match formula
    By namcheang in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2013, 08:08 PM
  4. Index & Match Formula & MACRO
    By Harry Basra in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-14-2013, 04:21 AM
  5. Macro to copy paste if match not found "go to next"
    By HawksOkeyoJr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-07-2013, 05:28 AM
  6. Replies: 3
    Last Post: 05-02-2013, 01:31 AM
  7. Replies: 5
    Last Post: 02-29-2012, 08:51 PM

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