Can't make two loops work

Solved/Closed
FRA - 12 Sep 2008 à 17:16
 FRA - 1 Oct 2008 à 16:59
Hello, here's my problem. I've got codes in column D that may show up more than once. On column A I've got a list of all available codes, and in column B the corresponding address. I want my macro to automatically replace each code in column D for its corresponding address.


Sub CambiarCodigos()
Dim iRow As Long
Dim jRow As Long
iRow = 3
jRow = 3
Do Until IsEmpty(Cells(iRow, "D"))
Do Until IsEmpty(Cells(jRow, "A")) 'works OK
Cells(iRow, "D") = Replace(Cells(iRow, "D"), Cells(jRow, "A"), Cells(jRow, "B")) 'works OK
jRow = jRow + 1 'works OK
Loop 'works OK
iRow = iRow + 1
Loop

End Sub

I really hope you can help!
Related:

1 response

Ivan-hoe Posts 433 Registration date Saturday 16 February 2008 Status Member Last seen 17 October 2008 110
13 Sep 2008 à 01:58
Hello FRA,
you're nearly there !
Move jRow = 3 immediately after Do Until IsEmpty(Cells(iRow, "D")) and it will work.
Ivan
Sub CambiarCodigos()
Dim iRow As Long, jRow As Long
iRow = 3
Do Until IsEmpty(Cells(iRow, "D"))
    jRow = 3
    Do Until IsEmpty(Cells(jRow, "A"))
etc.
Ivan, you're a genious. Thank you so very much!