I am hoping that some one could help me out with the following code.
I am getting an error 1004 - application defined or object defined error but Iv no idea why. Its showing on the line...
Its like its finding it because on debug the yellow highlight shows the search value am looking for. I think the problem is something to do with the "srcheader" part?
The larger part of the code is below
Thanks in advance
I am getting an error 1004 - application defined or object defined error but Iv no idea why. Its showing on the line...
VBA Code:
Set srchheader = Worksheets("Data").Range("G2:G" & lastrow).Find(Worksheets("Stats").Range(mycell.Offset(0, 1)).Value, LookAt:=xlWhole)
Its like its finding it because on debug the yellow highlight shows the search value am looking for. I think the problem is something to do with the "srcheader" part?
The larger part of the code is below
VBA Code:
Dim mycell As Range
Dim rng2 As Range
Dim league As String
Dim match As String
Dim srchheader As Range
Dim srchheader2 As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set rng2 = Worksheets("Stats").Range("A5:A100")
For Each mycell In rng2
If mycell.Value <> "" Then
match = mycell.Value
lastrow = Workbooks("NX01.xlsm").Worksheets("Data").Range("G" & Rows.Count).End(xlUp).Row
Set srchheader = Worksheets("Data").Range("G2:G" & lastrow).Find(Worksheets("Stats").Range(mycell.Offset(0, 1)).Value, LookAt:=xlWhole)
If Not srchheader Is Nothing Then
Worksheets("Stats").Range(mycell.Offset(0, 52)).Value = srchheader.Offset(0, -1).Value
End If
lastrow = Workbooks("NX01.xlsm").Worksheets("Data").Range("A" & Rows.Count).End(xlUp).Row
Set srchheader2 = Worksheets("Data").Range("A2:A" & lastrow).Find(What:=srcheader, LookAt:=xlWhole)
If Not srchheader2 Is Nothing Then
Worksheets("Stats").Range(mycell.Offset(0, 53)).Value = srchheader2.Offset(0, 1).Value
End If
Thanks in advance