FeltRubber
New Member
- Joined
- Oct 6, 2014
- Messages
- 4
Hey guys..
So i'm attempting to do a VLOOKUP on a list of names, the Lookup_Value being pulled from an added worksheet and the Lookup_Range being on a Master sheet (both within the same workbook)
The code works perfect when the VLOOKUP returns a value, but when returning the error '1004', it tells me the that the name is not on the master list and NEEDS TO BE ADDED TO IT.
So, I've been trying to run code from where the subroutine jumps to when the VLOOKUP returns a N/A value, but have had zero success. I am trying to take the names that are NOT found via the VLOOKUP and add them to the bottom of the master list
Here's a portion of what I have so far...
Any help would be greatly appreciated!
So i'm attempting to do a VLOOKUP on a list of names, the Lookup_Value being pulled from an added worksheet and the Lookup_Range being on a Master sheet (both within the same workbook)
The code works perfect when the VLOOKUP returns a value, but when returning the error '1004', it tells me the that the name is not on the master list and NEEDS TO BE ADDED TO IT.
So, I've been trying to run code from where the subroutine jumps to when the VLOOKUP returns a N/A value, but have had zero success. I am trying to take the names that are NOT found via the VLOOKUP and add them to the bottom of the master list
Here's a portion of what I have so far...
Code:
For b = 1 To players
playerName = Worksheets(newSheet).Range("A" & d).Value
playerScore = Application.VLookup(playerName, Sheets("Master").Range("A13:B500"), 2, False)
If IsError(playerScore) Then
Worksheets(newSheet).Range("A" & d).Copy Destination:=Range("A" & Rows.Count).End(xlUp).Offset(1)
Worksheets(newSheet).Range("C" & d).Copy Destination:=Range("B" & Rows.Count).End(xlUp).Offset(1)
Else
Set GCell = ThisWorkbook.Worksheets("Master").Cells.Find(playerName)
newPlayerScore = Worksheets(newSheet).Range("C" & d)
oldPlayerScore = Worksheets("Master").Range(GCell.Address).Offset(0, 1).Value
newPlayerScoreTotal = newPlayerScore + oldPlayerScore
Worksheets("Master").Range(GCell.Address).Offset(0, 1).Value = newPlayerScoreTotal
End If
d = d + 1
Next
Any help would be greatly appreciated!