ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Compare Col A and Col M, if Match, Copy Col N to Col E (https://www.excelbanter.com/excel-worksheet-functions/180902-compare-col-col-m-if-match-copy-col-n-col-e.html)

ryguy7272

Compare Col A and Col M, if Match, Copy Col N to Col E
 
I'm trying to get this macro to compare values in Column A and Column M,
starting in Cell(2, 13), and if there is a match, copy the value from Column
N (that corresponds to Column M) into Column E. For instance, 4/1/2008 is
in Cell A1 (and the dates go down consecutively). I have 4/6/2008 in M2 and
5,000,000 in N2. How can I get 5,000,000 into E6 (A6 contains 4/6/2008)?
Confused yet? I am.

Sub MatchAandM()
Dim Lrow As Long
Dim Rng As Range, i As Range, xRng As Range

Lrow = Range("A65536").End(xlUp).Row
Set Rng = Range(Cells(2, 13), Cells(Lrow, 2))

For Each i In Rng
Set xRng = Rng.Find(What:=i.Offset(0, -1).Value, _
LookIn:=xlValues, MatchCase:=False)
If xRng Is Nothing Then
'Else
i.Offset(0, -1).Copy i.Offset(0, 1)
End If
Next i

End Sub


Thanks for the help; I truly appreciate it.

Regards,
Ryan--
RyGuy

ryguy7272

Compare Col A and Col M, if Match, Copy Col N to Col E
 
Whoops! Just realized I posted to the excel-Functions group. I'm going over
to the Excel-Programming group now...
--
RyGuy


"ryguy7272" wrote:

I'm trying to get this macro to compare values in Column A and Column M,
starting in Cell(2, 13), and if there is a match, copy the value from Column
N (that corresponds to Column M) into Column E. For instance, 4/1/2008 is
in Cell A1 (and the dates go down consecutively). I have 4/6/2008 in M2 and
5,000,000 in N2. How can I get 5,000,000 into E6 (A6 contains 4/6/2008)?
Confused yet? I am.

Sub MatchAandM()
Dim Lrow As Long
Dim Rng As Range, i As Range, xRng As Range

Lrow = Range("A65536").End(xlUp).Row
Set Rng = Range(Cells(2, 13), Cells(Lrow, 2))

For Each i In Rng
Set xRng = Rng.Find(What:=i.Offset(0, -1).Value, _
LookIn:=xlValues, MatchCase:=False)
If xRng Is Nothing Then
'Else
i.Offset(0, -1).Copy i.Offset(0, 1)
End If
Next i

End Sub


Thanks for the help; I truly appreciate it.

Regards,
Ryan--
RyGuy



All times are GMT +1. The time now is 06:14 PM.

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