Search and Paste for accounts on 2 sheets
I have two worksheets, one contains accounts with yearly columns and the other sheet contains accounts with total money spent.
Sheet 1:
account-------------2015----------2016-----------2017
112
113
114
115
sheet 2:
account-------------total
112----------------50
113----------------100
115----------------15
Now I need for excel to check sheet 1 and find a match in sheet 2 and copy the value from sheet 2 into sheet 1.
So for this example sheet under the 2015 column on sheet 1 112,113, & 115 would have values but 114 would be skipped.
Here is the psuedocode I have completed so far.
Sub ()
worksheets("sheet 1").range("A1")=n <vendor names with year comparison>
worksheets("sheet 2").range("A1")=m <vendor names with amount spent>
worksheets("sheet 2").range("B1")=p <amount spent on vendor>
worksheets("sheet 1").range("B1")=q <2015 year column>
If n=m
then copy p
paste q
else
If n=m+1
then copy p+1
paste q+1
until worksheets("sheet 2").range("A208")
If n+1=m
then copy p
paste q+1
else
If n+1=m+1
then copy p+1
paste q+1
until worksheets("sheet 2").range("A208")
Repeat until n+1=worksheets("sheet 1").range("B2121")
end
Any help is appreciated.
|