I'm currently trying to run a Macro that looks for a value from column A of 'sheet 1' in column A of sheet 2, if these match then it should check the values from D3:M3 in Sheet1 against values in Column M in Sheet2, if they match then it should copy the corresponding values from SHeet1 D2 to M2, into ColumnP for Sheet2. I know it's a tricky one, so here's an exmple of what I need, and what I have done so far..
Now If you look at the 1st image that's sheet1, and 2nd image is Sheet 2 I need to check the userID(ColumnA) for sheet1, against the Awardexternal ID (ColumnA) for Sheet2, this is followed by another check - amount entered in Sheet2.ColumnM against the Amount entered in the corresponding UserID's row in this case D3 - M3.sheet1 :
Example - User A1111111 has enetered $100 as Mobile Phone Bill expense, all I want to do is check for the user id, then compare the amount they have entered and then paste the right "TYPE" of expense (in this case - Mobile phone Bill) in sheet2 Column P.
What I've done so far is:
Application.ScreenUpdating = False
Dim j As Long, i As Long, lastRow1 As Long, lastRow2 As Long
Dim MyName As String
lastRow1 = ws1.UsedRange.Rows.Count
For j = 2 To lastRow1
MyName = ws1.Cells(j, 1).Value
lastRow2 = ws2.UsedRange.Rows.Count
For i = 2 To lastRow2
If ws2.Cells(i, 3).Value = MyName Then
ws2.Cells(i, 13).Value = ws1.Cells(j, 2).Value
End If
Next i
Next j
Application.ScreenUpdating = True
When I try and run this, it just crashes the workbook. and nothing happens.
PS - I'm new to VBA, and do not have any experience in it. whatever I have done is googling and then trying to make the logic work.
Any help is appreciated! Thanks in advance!! :)