Excel VBA find, match and append worksheet values?

otivo

New Member
Joined
Jun 18, 2010
Messages
6
On May 11th, 2008, 06:38 PM, MrExcelMVP "Fazza" provided an excellent code in response to a request by "gravy679" titled "Match and replace cell from another sheet": http://www.mrexcel.com/forum/showthread.php?t=318911

Sub test()
Application.ScreenUpdating = False
Dim cel As Range

For Each cel In Worksheets("Sheet1").Range("B1").CurrentRegion.Columns(2).Cells
Worksheets("Sheet2").Columns(1).Replace What:=cel.Value, Replacement:=cel.Offset(, -1).Value, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, MatchCase:=True
Next cel
End Sub

I am in need of VBA code does not NOT replace, rather appends to another cell. I believe it will be quite close to the functions in Fazza's code above, but produce slightly different results.

If any cell in Workbook 2, Sheet 1, Column B = any cell in Workbook 1, Sheet 1, Column B, then match value in Workbook 1, Sheet 1, Column A (A, B, C, etc) and enter matching result in Workbook 2, Sheet 1, Column A.

WORKBOOK 1
SHEET 1
COL A. COL B.
A JANUARY
B FEBRUARY
C MARCH
D APRIL
E MAY


WORKBOOK 2
SHEET 1
COL A. COL B.
DECEMBER
JANUARY
DECEMBER
JANUARY
APRIL
DECEMBER
AUGUST
FEBRUARY
FEBRUARY
DECEMBER
JANUARY
DECEMBER
JANUARY
APRIL
MAY
JANUARY

Result should be as follows on Workbook 2, Sheet 1:

COL A. COL B.
L DECEMBER
A JANUARY
L DECEMBER
A JANUARY
D APRIL
L DECEMBER
H AUGUST
B FEBRUARY
B FEBRUARY
L DECEMBER
A JANUARY
L DECEMBER
A JANUARY
D APRIL
E MAY
A JANUARY

As I am a complete novice with VBA code, I am not aware if macros can be executed to check against multiple workbooks. If not, I could always combine the data on one workbook, and use Sheet 1 and 2 - if necessary. Alternatively, I could have all the data in Sheet 1 only if that makes it even simpler.

Thanks for your time and input.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,215,483
Messages
6,125,064
Members
449,206
Latest member
Healthydogs

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