jmsantoro71
New Member
- Joined
- Apr 29, 2016
- Messages
- 11
<small style="box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 11.04px; text-transform: uppercase; display: block; color: rgb(105, 109, 111); font-family: 'Helvetica Neue', roboto, Arial, sans-serif; -webkit-tap-highlight-color: transparent !important; outline: 0px !important; background-color: rgb(238, 242, 244);"><small style="box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 11.04px; display: block; -webkit-tap-highlight-color: transparent !important; outline: 0px !important;">I'm new to VBA and this code is kicking my tail. I've been updating the price sheets one record at a time but am trying desperately to write code I can use for each new update. Will someone please help???? Here's what I've got...
I HAVE TWO WORKBOOKS. ONE NAMED "MASTER" AND ANOTHER NAMED "UPDATE". THEY ARE THE SAME IN REGARDS TO STRUCTURE AND FORMAT. ONLY SOME OF THE DATA IS DIFFERENT. IN BOTH WORKBOOKS, COLUMN A CONTAINS MODEL NUMBERS. COLUMNS K & L CONTAIN CORRESPONDING PRICES FOR THOSE MODEL NUMBERS IN COLUMN A. THE SAME EXISTS FOR COLUMN N (MODEL NUMBERS) AND COLUMNS X & Y (PRICES). IN BOTH WORKBOOKS ALL PRICES ARE EITHER (FONT COLOR) BLACK, RED OR BLUE. THE FILE IS FORMATTED TO PRINT AS A PRICE SHEET. THEREFORE, THE DATA FIELDS (MODEL NUMBER AND CORRESPONDING INFO) IS DUPLICATED (THE FIELDS, NOT THE DATA) ON THE WORKSHEET IN ORDER TO GET MORE PER PRINTED PAGE INSTEAD OF HAVING EACH DATA FIELD LIMITED TO ONE COLUMN EACH.
MY TASK IS TO COMPARE THE TWO WORKBOOKS LOOKING FOR MODEL NUMBERS IN THE "UPDATE" WORKBOOK WHICH ARE ALSO FOUND IN "MASTER". (COLUMNS A & N IN BOTH WORKBOOKS) WHEN A DUPLICATE MODEL NUMBER IS DETECTED, USING THE "MASTER" MODEL NUMBER, CHECK THE PRICE IN COLUMN K. IF IT IS BLACK, DO NOTHING. IF IT IS RED OR BLUE, COPY IT AND PASTE IT ON THE "UPDATE" WORKBOOK IN COLUMN K IN THE ROW OF THE CORRESPONDING MODEL NUMBER. THEN, DO THE SAME FOR THE PRICE IN COLUMN L. THE SAME PROCESS WOULD BE APPLIED TO THE MODEL NUMBERS IN COLUMN N AND THE CORRESPONDING PRICES IN COLUMNS X & Y. SO, THE END RESULT WOULD BE... FROM THE MASTER WORKBOOK ANY PRICES WHICH ARE RED OR BLUE WOULD BE INSERTED INTO THE CORRECT LOCATION IN THE UPDATE WORKBOOK. ANY BLACK PRICES IN THE MASTER WORKBOOK ARE LEFT ALONE. HERE IS A SAMPLE OF WHAT IT LOOKS LIKE...
</small></small>[TABLE="class: cms_table, width: 1000"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[TD]L[/TD]
[TD]M[/TD]
[TD]N[/TD]
[TD]O[/TD]
[TD]P[/TD]
[TD]Q[/TD]
[TD]R[/TD]
[TD]S[/TD]
[TD]T[/TD]
[TD]U[/TD]
[TD]V[/TD]
[TD]W[/TD]
[TD]X[/TD]
[TD]Y[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Model[/TD]
[TD]Desc 1[/TD]
[TD]Desc 2[/TD]
[TD]Mfg[/TD]
[TD]Series[/TD]
[TD]Code 1[/TD]
[TD]Code 2[/TD]
[TD]Code 3[/TD]
[TD]Code 4[/TD]
[TD]Code 5[/TD]
[TD]B Price[/TD]
[TD]A Price[/TD]
[TD][/TD]
[TD]Model[/TD]
[TD]Desc 1[/TD]
[TD]Desc 2[/TD]
[TD]Mfg[/TD]
[TD]Series[/TD]
[TD]Code 1[/TD]
[TD]Code 2[/TD]
[TD]Code 3[/TD]
[TD]Code 4[/TD]
[TD]Code 5[/TD]
[TD]B Price[/TD]
[TD]A Price[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]cpx43w[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]123[/TD]
[TD]435[/TD]
[TD][/TD]
[TD]gft43th[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]665[/TD]
[TD]546[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]gxf4ts[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]321[/TD]
[TD]345[/TD]
[TD][/TD]
[TD]ggt45d[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]398[/TD]
[TD]776[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]htf45ty[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]435[/TD]
[TD]765[/TD]
[TD][/TD]
[TD]we324s[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]458[/TD]
[TD]456[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]pdf12ys[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]542[/TD]
[TD]356[/TD]
[TD][/TD]
[TD]rd4432[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]869[/TD]
[TD]775[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]dd34rtd[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]1900[/TD]
[TD]1965[/TD]
[TD][/TD]
[TD]trh556[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]334[/TD]
[TD]356[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]ct35ddr[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]2344[/TD]
[TD]3211[/TD]
[TD][/TD]
[TD]th99yth[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]545[/TD]
[TD]345[/TD]
[/TR]
</tbody>[/TABLE]
<small style="box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 11.04px; text-transform: uppercase; display: block; color: rgb(105, 109, 111); font-family: 'Helvetica Neue', roboto, Arial, sans-serif; -webkit-tap-highlight-color: transparent !important; outline: 0px !important; background-color: rgb(238, 242, 244);"><small style="box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 11.04px; display: block; -webkit-tap-highlight-color: transparent !important; outline: 0px !important;">
ABOVE IS AN EXAMPLE OF THE MASTER WOORKBOOK. THE UPDATE WORKBOOK IS FORMATTED EXACTLY THE SAME EXCEPT ALL PRICING IS BLACK (FONT COLOR). IF A MODEL NUMBER IS FOUND IN THE UPDATE WORKBOOK WHICH IS ALSO IN THE MASTER WORKBOOK, AND THE PRICES FOR THAT MODEL NUMBER IN THE MASTER WORKBOOK ARE RED OR BLUE THOSE PRICES (AND FONT COLOR) NEED TO BE COPIED AND PASTED OVER THE PRICES IN THE UPDATE WORKBOOK. IF THE FONT COLOR OF THE PRICES IN THE MASTER WORKBOOK ARE BLACK, NOTHING IS DONE TO THE PRICES IN THE UPDATE FOR THAT MODEL.</small></small>
I HAVE TWO WORKBOOKS. ONE NAMED "MASTER" AND ANOTHER NAMED "UPDATE". THEY ARE THE SAME IN REGARDS TO STRUCTURE AND FORMAT. ONLY SOME OF THE DATA IS DIFFERENT. IN BOTH WORKBOOKS, COLUMN A CONTAINS MODEL NUMBERS. COLUMNS K & L CONTAIN CORRESPONDING PRICES FOR THOSE MODEL NUMBERS IN COLUMN A. THE SAME EXISTS FOR COLUMN N (MODEL NUMBERS) AND COLUMNS X & Y (PRICES). IN BOTH WORKBOOKS ALL PRICES ARE EITHER (FONT COLOR) BLACK, RED OR BLUE. THE FILE IS FORMATTED TO PRINT AS A PRICE SHEET. THEREFORE, THE DATA FIELDS (MODEL NUMBER AND CORRESPONDING INFO) IS DUPLICATED (THE FIELDS, NOT THE DATA) ON THE WORKSHEET IN ORDER TO GET MORE PER PRINTED PAGE INSTEAD OF HAVING EACH DATA FIELD LIMITED TO ONE COLUMN EACH.
MY TASK IS TO COMPARE THE TWO WORKBOOKS LOOKING FOR MODEL NUMBERS IN THE "UPDATE" WORKBOOK WHICH ARE ALSO FOUND IN "MASTER". (COLUMNS A & N IN BOTH WORKBOOKS) WHEN A DUPLICATE MODEL NUMBER IS DETECTED, USING THE "MASTER" MODEL NUMBER, CHECK THE PRICE IN COLUMN K. IF IT IS BLACK, DO NOTHING. IF IT IS RED OR BLUE, COPY IT AND PASTE IT ON THE "UPDATE" WORKBOOK IN COLUMN K IN THE ROW OF THE CORRESPONDING MODEL NUMBER. THEN, DO THE SAME FOR THE PRICE IN COLUMN L. THE SAME PROCESS WOULD BE APPLIED TO THE MODEL NUMBERS IN COLUMN N AND THE CORRESPONDING PRICES IN COLUMNS X & Y. SO, THE END RESULT WOULD BE... FROM THE MASTER WORKBOOK ANY PRICES WHICH ARE RED OR BLUE WOULD BE INSERTED INTO THE CORRECT LOCATION IN THE UPDATE WORKBOOK. ANY BLACK PRICES IN THE MASTER WORKBOOK ARE LEFT ALONE. HERE IS A SAMPLE OF WHAT IT LOOKS LIKE...
</small></small>[TABLE="class: cms_table, width: 1000"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[TD]L[/TD]
[TD]M[/TD]
[TD]N[/TD]
[TD]O[/TD]
[TD]P[/TD]
[TD]Q[/TD]
[TD]R[/TD]
[TD]S[/TD]
[TD]T[/TD]
[TD]U[/TD]
[TD]V[/TD]
[TD]W[/TD]
[TD]X[/TD]
[TD]Y[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Model[/TD]
[TD]Desc 1[/TD]
[TD]Desc 2[/TD]
[TD]Mfg[/TD]
[TD]Series[/TD]
[TD]Code 1[/TD]
[TD]Code 2[/TD]
[TD]Code 3[/TD]
[TD]Code 4[/TD]
[TD]Code 5[/TD]
[TD]B Price[/TD]
[TD]A Price[/TD]
[TD][/TD]
[TD]Model[/TD]
[TD]Desc 1[/TD]
[TD]Desc 2[/TD]
[TD]Mfg[/TD]
[TD]Series[/TD]
[TD]Code 1[/TD]
[TD]Code 2[/TD]
[TD]Code 3[/TD]
[TD]Code 4[/TD]
[TD]Code 5[/TD]
[TD]B Price[/TD]
[TD]A Price[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]cpx43w[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]123[/TD]
[TD]435[/TD]
[TD][/TD]
[TD]gft43th[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]665[/TD]
[TD]546[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]gxf4ts[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]321[/TD]
[TD]345[/TD]
[TD][/TD]
[TD]ggt45d[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]398[/TD]
[TD]776[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]htf45ty[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]435[/TD]
[TD]765[/TD]
[TD][/TD]
[TD]we324s[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]458[/TD]
[TD]456[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]pdf12ys[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]542[/TD]
[TD]356[/TD]
[TD][/TD]
[TD]rd4432[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]869[/TD]
[TD]775[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]dd34rtd[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]1900[/TD]
[TD]1965[/TD]
[TD][/TD]
[TD]trh556[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]334[/TD]
[TD]356[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]ct35ddr[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]2344[/TD]
[TD]3211[/TD]
[TD][/TD]
[TD]th99yth[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]545[/TD]
[TD]345[/TD]
[/TR]
</tbody>[/TABLE]
<small style="box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 11.04px; text-transform: uppercase; display: block; color: rgb(105, 109, 111); font-family: 'Helvetica Neue', roboto, Arial, sans-serif; -webkit-tap-highlight-color: transparent !important; outline: 0px !important; background-color: rgb(238, 242, 244);"><small style="box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 11.04px; display: block; -webkit-tap-highlight-color: transparent !important; outline: 0px !important;">
ABOVE IS AN EXAMPLE OF THE MASTER WOORKBOOK. THE UPDATE WORKBOOK IS FORMATTED EXACTLY THE SAME EXCEPT ALL PRICING IS BLACK (FONT COLOR). IF A MODEL NUMBER IS FOUND IN THE UPDATE WORKBOOK WHICH IS ALSO IN THE MASTER WORKBOOK, AND THE PRICES FOR THAT MODEL NUMBER IN THE MASTER WORKBOOK ARE RED OR BLUE THOSE PRICES (AND FONT COLOR) NEED TO BE COPIED AND PASTED OVER THE PRICES IN THE UPDATE WORKBOOK. IF THE FONT COLOR OF THE PRICES IN THE MASTER WORKBOOK ARE BLACK, NOTHING IS DONE TO THE PRICES IN THE UPDATE FOR THAT MODEL.</small></small>