Index match VBA

anand3dinesh

Board Regular
Joined
Dec 19, 2019
Messages
137
Office Version
  1. 365
Platform
  1. Windows
Hi i'm a beginner can you please help me to wright VBA script for "Index match" that returns value from other worksheet?
please refer images i have 2 worksheets a and B in sheet b i need code that fills cells according to the column heading
 

Attachments

  • Sheet a.PNG
    Sheet a.PNG
    6.3 KB · Views: 11
  • Sheet b.PNG
    Sheet b.PNG
    3.8 KB · Views: 10
You're welcome & thanks for the feedback
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Oops, it should be
Rich (BB code):
Sub anand3dinesh()
    With Sheets("Sheet2")
        With .Range("B2:D" & .Range("A" & Rows.Count).End(xlUp).Row)
            .Formula = "=INDEX(Sheet1!$B$2:$D$9,MATCH($A2,Sheet1!$A$2:$A$9,0),MATCH(B$1,Sheet1!$B$1:$D$1,0))"
            .Value = .Value
        End With
    End With
End Sub
 
Upvote 0
Oops, it should be
Rich (BB code):
Sub anand3dinesh()
    With Sheets("Sheet2")
        With .Range("B2:D" & .Range("A" & Rows.Count).End(xlUp).Row)
            .Formula = "=INDEX(Sheet1!$B$2:$D$9,MATCH($A2,Sheet1!$A$2:$A$9,0),MATCH(B$1,Sheet1!$B$1:$D$1,0))"
            .Value = .Value
        End With
    End With
End Sub
Perfect thanks a lot
 
Upvote 0
one more doubt i need to return data with the help of other columns, suppose i create a unique identification number in middle of the table referring that column it should fill right and left columns
 
Upvote 0
My pleasure & thanks for the feedback
one more doubt i need to return data with the help of other columns, suppose i create a unique identification number in middle of the table referring that column it should fill right and left columns
 
Upvote 0
I'm afraid I haven't got a clue what you're talking about.
I suggest you download & install the XL2BB add-in & then use that to post some sample data in your reply with an explanation.

Also please do not duplicate your posts.
 
Upvote 0
I'm afraid I haven't got a clue what you're talking about.
I suggest you download & install the XL2BB add-in & then use that to post some sample data in your reply with an explanation.

Also please do not duplicate your posts.

please refer image i have created new column called "Code" it is in between, referring that column other column should fill
 

Attachments

  • Capture.PNG
    Capture.PNG
    7.1 KB · Views: 4
Upvote 0
You need to change the references from D to your last column, both in the Range & in the formula
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,973
Members
449,200
Latest member
Jamil ahmed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top