+ Reply to Thread
Results 1 to 5 of 5

VBA Index Match type function

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    108

    VBA Index Match type function

    Hi All,

    I have a Spreadsheet I would like to copy some cell values from 1 sheet and paste into another sheet

    However where it is to paste the information, depends on 2 cell values on sheet 1, the employee name, and the date.

    So I need the code to look at the cell on sheet 1 with the employee name, and look for that value in column A of sheet 2. That will return the initial row where I want to paste.

    But I also need it to look at the cell on sheet 1 with the date selected, and look for that value in Row 1 of sheet 2, thus returning the Column of where I want to paste

    This will hopefully give a cell to paste into. I've attached an Example workbook to help try make sense. The Values I want to copy are Sheet 1 D9:G9, and the paste on sheet 2 depending on the above criteria

    However the 4 values will be pasted down the way; ex. B2:B5

    Hope somebody can help with this issue, Im not the worst at VBA but would still be a noob
    Attached Files Attached Files

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Index Match type function

    maybe
    Sub matchEm()
        Dim vRow, vColumn
        Dim sht1 As Excel.Worksheet
        Dim sht2 As Excel.Worksheet
        
        
        Set sht1 = Sheets("Sheet1")
        Set sht2 = Sheets("Sheet2")
        vRow = Application.Match(sht1.Range("B1").Value, sht2.Range("B:B"), 0)
        If Not IsError(vRow) Then
            vColumn = Application.Match(sht1.Range("B4").Value2, sht2.Range("1:1"), 0)
            If Not IsError(vColumn) Then sht2.Cells(vRow, vColumn).Resize(4).Value = Application.Transpose(sht1.Range("D9:G9").Value)
        End If
    End Sub
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: VBA Index Match type function

    option for the button on Sheet1 code:

    Sub test()
    
    On Error Resume Next
    Sheets(2).UsedRange.Find(Range("b1"), , xlValues, xlWhole).Offset(, Application.Match(Range("b4"), Sheets(2).Rows(1), 0) - 2).Resize(4).Value = Application.Transpose(Range("d9:g9"))
    
    End Sub

  4. #4
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    108

    Re: VBA Index Match type function

    Hi,

    Sorry about the slow reply, was travelling. Those codes worked a treat. Rep added

    Thanks

  5. #5
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    108

    Re: VBA Index Match type function

    Hi,

    Sorry about the slow reply, was travelling. Those codes worked a treat. Rep added

    Thanks

+ 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] Need help with INDEX+MATCH type function
    By bxk006 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-09-2014, 11:39 AM
  2. [SOLVED] Index/Match lookup with two columns - Runtime Type 13 Error
    By connor12 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-17-2014, 09:52 PM
  3. Index and Match with Two Criteria, and date Match Type is Less Than
    By ExcelQuestion in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 11-11-2013, 08:57 AM
  4. [SOLVED] Only text values matching using index/match lookup - data type pro
    By Stanton in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  5. Looking for formula index/match-type that returns an array
    By Tom in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-01-2005, 05:06 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