+ Reply to Thread
Results 1 to 8 of 8

VBA to populate cells based on another cell using Index and Match

  1. #1
    Forum Contributor
    Join Date
    02-23-2014
    Location
    Melbourne
    MS-Off Ver
    Microsoft 365
    Posts
    174

    VBA to populate cells based on another cell using Index and Match

    Hi Experts
    Can someone please help me with the below problem

    I have a worksheet with some headers and when data is entered in G7, the Index & Match looks at the data in the Database table and auto-populates H7, I7, J7 & K7

    So if something is entered in G8, it populates the other cells and so on

    Thank You, I have attached a sample file

    Regards
    Rahul
    Attached Files Attached Files

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: VBA to populate cells based on another cell using Index and Match

    Not using Index and Match, my preference is auto filer I've set up a solution. To test run "Add Tag"

    I did on change to your original file. I converted the table range on the "Database" sheet to a "normal" range. If you need it in table format macro can be modified to
    convert this range back to a table again.

    Alf
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Exclamation


    Hi !

    As he already had a solution in his previous thread, so a duplicate thread here …

  4. #4
    Forum Contributor
    Join Date
    02-23-2014
    Location
    Melbourne
    MS-Off Ver
    Microsoft 365
    Posts
    174

    Re: VBA to populate cells based on another cell using Index and Match

    Hi Alf
    Thanks for that
    The Database sheet needs to be in a table format

    Regards
    Rahul

  5. #5
    Forum Contributor
    Join Date
    02-23-2014
    Location
    Melbourne
    MS-Off Ver
    Microsoft 365
    Posts
    174

    Re: VBA to populate cells based on another cell using Index and Match

    Hi Marc
    Sorry for the confusion
    In the previous thread the request was to do a Index and Match on a table

    For some reasons i had to convert the table to a range and because I did that the VBA you had provided stopped working and i cant get it to work on a range
    I started a new thread as the requirements changed

    Now I need something that would look at the range and do a Index and Match based on what is entered in the column G

    The below is the VBA you had given me for a table

    Private Sub Worksheet_Change(ByVal Target As Range)
    Const D = "Database"
    Dim Rg As Range
    If Not Intersect(Me.ListObjects("TAG_Data").DataBodyRange.Columns(6), Target(1)) Is Nothing Then
    Set Rg = Worksheets(D).ListObjects(D).DataBodyRange.Columns(1).Find(Target(1).Value, , xlValues, xlWhole)
    Application.EnableEvents = False
    With Target(1, 2).Resize(, 3)
    If Rg Is Nothing Then
    .ClearContents
    Else
    .Value = Rg(1, 2).Resize(, 3).Value
    Set Rg = Nothing
    End If
    End With
    Application.EnableEvents = True
    End If
    End Sub


    Regards
    Rahul

  6. #6
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: VBA to populate cells based on another cell using Index and Match

    The Database sheet needs to be in a table format
    For what it's worth, this line will convert the table "Database" to a normal range

    Please Login or Register  to view this content.
    and these lines will convert the range back to a table

    Please Login or Register  to view this content.
    As these commands uses "ActiveSheet" sheet "Datsbase" must be activated, or you can use

    Please Login or Register  to view this content.
    in which case you don't need to activate the sheet before running the command.

    Alf

  7. #7
    Forum Contributor
    Join Date
    02-23-2014
    Location
    Melbourne
    MS-Off Ver
    Microsoft 365
    Posts
    174

    Re: VBA to populate cells based on another cell using Index and Match

    Thanks, Alf
    Suit my needs

    Thanks for your help
    Regards
    Rahul

  8. #8
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: VBA to populate cells based on another cell using Index and Match

    You are welcome

    Thanks for rep and feedback.

    Alf

+ 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] Populate a cell based of a match - Match/vlookup
    By jambo2013 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2018, 06:55 AM
  2. Populate a cell based of a match - Match/vlookup
    By jambo2013 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-24-2018, 11:04 AM
  3. Creating INDEX MATCH MATCH formula based off text in cells
    By bbkdude in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-26-2017, 10:37 AM
  4. Using Lookup? Index match? to populate cells based on column header
    By NoExcelSkills17 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-15-2015, 03:50 PM
  5. [SOLVED] Index Match to populate a diary based on trainer availability
    By Smudge.Smith in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-05-2014, 11:17 PM
  6. [SOLVED] Index Match/Populate data based on key value
    By mzafar in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-03-2013, 01:49 PM
  7. Replies: 8
    Last Post: 12-18-2012, 05:18 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