VBA Index Match

John J

Board Regular
Joined
Feb 7, 2005
Messages
58
I have the following code which is not giveing any result and not showing a fault. Can any one tell me what is wrong.
Two work sheets in the same book. One holding the "Information" And the Active sheet (as there will be more than one) Which needs data adding to it from the Information sheet.
The locals window give the expected results down to "ActWs.Range("L" & X).Value ="
Thanks in Advance

Sub test()

Dim ActWs As Worksheet, InfWs As Worksheet
Dim ActWsLastRow As Long, InfLastRow As Long, X As Long
Dim IndexRng As Range, MatchRng As Range

Set ActWs = ActiveSheet
Set InfWs = ThisWorkbook.Worksheets("Information")

ActWsLastRow = ActWs.Range("A" & Rows.Count).End(xlUp).Row
InfLastRow = InfWs.Range("A" & Rows.Count).End(xlUp).Row

Set IndexRng = InfWs.Range("B4:D" & InfLastRow)
Set MatchRng = InfWs.Range("A4:A" & InfLastRow)
'Set MatchRng = IndexRng.offset(0, 1)

For X = 4 To Range("A" & Rows.Count).End(xlUp).Row 'ActWsLastRow
On Error Resume Next
ActWs.Range("L" & X).Value = Application.WorksheetFunction.Index(IndexRng, _
Application.WorksheetFunction.Match(ActWs.Range("A" & X).Value.MatchRng, 0), 2)




Next X


End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
This line looks wrong, should be a comma between Value and MatchRng, not a dot.

VBA Code:
ActWs.Range("L" & X).Value = Application.WorksheetFunction.Index(IndexRng, _
Application.WorksheetFunction.Match(ActWs.Range("A" & X).Value.MatchRng, 0), 2)
 
Upvote 0

Forum statistics

Threads
1,214,422
Messages
6,119,395
Members
448,891
Latest member
tpierce

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