Index with multiple match (Loop) when one of the Match is a Date ( VBA ) - Value Mismatch

xs4amit

New Member
Joined
May 21, 2018
Messages
34
Hi I am trying to do index match Loop through Columns first and then Rows with multiple criteria in VBA

My Source data is like:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Date[/TD]
[TD]email ID[/TD]
[TD]Attendance Status[/TD]
[/TR]
[TR]
[TD]22/08/18[/TD]
[TD]Bob22@tiptop.com[/TD]
[TD]Present[/TD]
[/TR]
[TR]
[TD]22/08/18[/TD]
[TD]Milan@tiptop.com[/TD]
[TD]Present[/TD]
[/TR]
[TR]
[TD]22/08/18[/TD]
[TD]Samuel@tiptop.com[/TD]
[TD]Present[/TD]
[/TR]
[TR]
[TD]23/08/18[/TD]
[TD]Bob22@tiptop.com[/TD]
[TD]Planned Leave[/TD]
[/TR]
[TR]
[TD]23/08/18[/TD]
[TD]Milan@tiptop.com[/TD]
[TD]Present[/TD]
[/TR]
[TR]
[TD]23/08/18[/TD]
[TD]Samuel@tiptop.com[/TD]
[TD]Present[/TD]
[/TR]
[TR]
[TD]24/08/18[/TD]
[TD]Bob22@tiptop.com[/TD]
[TD]Present[/TD]
[/TR]
[TR]
[TD]24/08/18[/TD]
[TD]Milan@tiptop.com[/TD]
[TD]Unplanned Leave[/TD]
[/TR]
</tbody>[/TABLE]


And my Destination Data should be like this:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Email IDs[/TD]
[TD]22/08/18[/TD]
[TD]23/08/18[/TD]
[TD]24/08/18[/TD]
[/TR]
[TR]
[TD]Bob22@tiptop.Com[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Milan@tiptop.com[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Samuel@tiptop.com[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Where as i am using Code with Worksheet function

With Destination
.Range("B2:D4").Clear
For R = 2 To 4
For C = 2 To UBound(Arr2, 2)

.Cells(R, C) = .Application.WorksheetFunction.Index(Source.Range("A2:C30000"), _
.Application.WorksheetFunction.Match(.Cells(R, 1) & CDate(.Cells(1, C)), WS1.Range("B2:B30000") & WS1.Range("A2:A30000"), 0), 3)


Next C


Next R
.Activate
End With


End Sub

it is giving me Type Mismatch Error. Any help??

I am using Excel 2016 on Mac.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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