VBA Loop Comparing Two Cells and Copying Value when True

nalij

Board Regular
Joined
Jul 31, 2012
Messages
52
Thanks in advance to anyone that can offer assistance to me with this issue, I am really stumped.

Background:
I have a pivot table with a number of slicers that drive the data. On a separate worksheet I am graphing specific values based on a specific time period.

Issue:The problem I run into is some of the slicers change the layout of the pivottable (i.e.: 1/7 data might be in column C for slicer 1 then column B for slicer 2).

I believe the most efficient approach would be to write a loop code that looks at the pivot table and compares the two dates, if the date matches then select the corresponding pivottable value and paste on the graphing worksheet. Run this through until the pivottable has compared all dates to the graphing table.

Layout:

So compare the dates here (Worksheet 2), represented horizontally
MetricWeekVal
VENDORNAME01/04/1301/11/1301/25/1302/01/1302/15/1303/01/1303/22/1303/29/1304/05/13Grand Total
Vendor 10110101110.666666667
Grand Total0110101110.666666667

<tbody>
</tbody>

to the dates here (Worksheet 1), represented vertically
01/18/13
01/25/13
02/01/13
02/08/13
02/15/13
02/22/13
03/01/13
03/08/13
03/15/13
03/22/13
03/29/13
04/05/13

<tbody>
</tbody>

If the dates match then take the value from Worksheet 2 and place it in the column immediately to the right of the dates in Worksheet 1. Repeat this process until all the pivottable metric value information is contained within the vertical (Worksheet 1) graphing table.



Thanks again to anyone that can offer advice or proposed solution!!!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,196,120
Messages
6,013,577
Members
441,774
Latest member
esandoval

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