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.
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.