View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz[_2_] JLGWhiz[_2_] is offline
external usenet poster
 
Posts: 1,565
Default a Disaster in the Making - R/T error 1004

Not sure this is the problem, but you changed the value of SRng(i) in the
first loop, after it has been found and before the FindNext. i = i + 1


"JMay" wrote in message
...
I've been trying to debug the below code for better than 3 hours, without
success.
Can someone help me?

Sub NewMatchStuff()
Set SRng = Worksheets("TheHdr").Range("D3", Range("D" &
Rows.Count).End(xlUp))
Set DRng = Worksheets("Hdr formula").Range("A1:T1")
i = 1
With DRng
Do
Set g = .Find(SRng(i))
If Not g Is Nothing Then
faddress = g.Address
g.Offset(1).Value = SRng(i).Offset(0, -2).Value
End If
i = i + 1
Loop Until Not g Is Nothing
Do
Set g = Nothing 'Need to reset g to Nothing
Set g = .FindNext(SRng(i)) '*** R/T 1004 Here
i = i + 1
Loop While Not g Is Nothing And g.Address < faddress
End With
End Sub