Macro to copy a number to other sheet based on two conditions

PSV86

New Member
Joined
Dec 15, 2017
Messages
8

<tbody></tbody>
Hello there!

I’m just breaking my brains to do this and I ask your help!

I made it without a problem using match and index but is really slow and I want to try it with a macro.

Two sheets, one called Data, and other called Report.

Data has 3 columns, A contains a date, B contains a name, and C (that’s the important one, contains a number) and it has a lot of rows with information.

Reports contains 9 columns
A is equal a different names
B to I are iqual to dates

So I have something like that:

Data:
12/12/17Name 18
12/13/17Name 16
12/15/17Name 28
12/15/17Name 75

<tbody>
</tbody>

Report:
Name12/13/1712/14/1712/15/1712/16/1712/17/1712/18/1712/19/1712/20/17
Name 1
Name 2
Name 3
Name 4
Name 5
Name 6
Name 7
Name 8
Name 9

<tbody>
</tbody>



So what I need?
If the date and the name in the Data sheet, is the same as the date and the name in Report, then copy the number.

Using the example posted the result it will be:
Name12/13/1712/14/1712/15/1712/16/1712/17/1712/18/1712/19/1712/20/17
Name 1
6
Name 2
8
Name 3
Name 4
Name 5
Name 6
Name 75
Name 8
Name 9

<tbody>
</tbody>

The formula in the sheet Report in B2 (and so on) used to achieve this results is:
{=IFNA(INDEX(Data!$A:$C,MATCH(1,(Data!$B:$B=$A2)*(Data!$A:$A=B$1),0),3),0)}

I hope you can help me and learn how to do it in the process examining the reply’s!

Thanks a lot!!
 
Try changing the last bit of code for the bit of code below:-
Code:
For Each Dn In nRng
   If Dic.exists(Dn.Value) Then
      If Dic(Dn.Value).exists(Dn.Offset(, -1).Value) Then
         Q = Dic(Dn.Value).Item(Dn.Offset(, -1).Value)
         Q(0).Offset(, Q(1)).Value = Dn.Offset(, 1).Value
      End If
   End If
Next Dn
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I don’t know what to say... it works shockingly well
I tried with a future date, with an old one, writing a letter instead of a number, it simply works!

Thanks a lot for everything, as I said now is time to study all this references that I don’t understand in the code :) and still learning about Excel VBA :)

I hope I can help someone as you helped me!
 
Upvote 0

Forum statistics

Threads
1,215,335
Messages
6,124,327
Members
449,155
Latest member
ravioli44

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