ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Writing a macro to compare columns and return a value (https://www.excelbanter.com/excel-discussion-misc-queries/235464-writing-macro-compare-columns-return-value.html)

Ginny

Writing a macro to compare columns and return a value
 
Hello,

I am trying to write a macro to compare 2 columns and then return a
scpeficied value. Eventually, I will have approx 5000 lines to compare in the
columns, so I am trying to create a macro with a specified function that will
do thi, but can't figure out the function.

Here is what I want:
I want to see if the specificed EMO_ID Numb (for example, the number in cell
B7, whcih is 83) can be found anywhere in the BSNIP_ID column. If it it
found, then I want the number in cell B7 (which is #83) to be copied over to
the adjacent column (Numbers found), in cell C7. Can a macro be written to
search, find, numbers, and return a value for approx 5000 numbers?

BSNIP_ID EMO_ID Numb Numbers found
1 1
2 2
3 3
4 4
21 40
26 40
28 83
40 86
42 93
44 94
83 118
86 139
93 145
94 176
118 205
122 233
126 239
129 263
135 270


Thank you for your help!
--
Ginny

Don Guillett

Writing a macro to compare columns and return a value
 
Maybe a FINDNEXT macro would do as desired. Look in the vba help index.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Ginny" wrote in message
...
Hello,

I am trying to write a macro to compare 2 columns and then return a
scpeficied value. Eventually, I will have approx 5000 lines to compare in
the
columns, so I am trying to create a macro with a specified function that
will
do thi, but can't figure out the function.

Here is what I want:
I want to see if the specificed EMO_ID Numb (for example, the number in
cell
B7, whcih is 83) can be found anywhere in the BSNIP_ID column. If it it
found, then I want the number in cell B7 (which is #83) to be copied over
to
the adjacent column (Numbers found), in cell C7. Can a macro be written to
search, find, numbers, and return a value for approx 5000 numbers?

BSNIP_ID EMO_ID Numb Numbers found
1 1
2 2
3 3
4 4
21 40
26 40
28 83
40 86
42 93
44 94
83 118
86 139
93 145
94 176
118 205
122 233
126 239
129 263
135 270


Thank you for your help!
--
Ginny




All times are GMT +1. The time now is 01:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com