Hello,
I am trying to build some macro that would replace some word from a table, based on a list of words, and paste each time the table one after the other.
Example:
If that makes sense already... this is what i was trying so far, i am just stuck in how to make the replacement word change to next one of the list of the with list. And how to paste at the end of the new list..
Hope it makes sense and someone can help me with this one.
thanks in advance!
I am trying to build some macro that would replace some word from a table, based on a list of words, and paste each time the table one after the other.
Example:
Cat1 | 10 | Replace | Cat | Horse1 | 10 | ||
Cat2 | 20 | With | Horse | Horse2 | 20 | ||
Cat3 | 30 | Cow | Horse3 | 30 | |||
Cat4 | 40 | Dog | Horse4 | 40 | |||
Cat5 | 50 | Sheep | Horse5 | 50 | |||
Cat6 | 60 | Mouse | Horse6 | 60 | |||
Cat7 | 70 | Horse7 | 70 | ||||
Cat8 | 80 | Horse8 | 80 | ||||
Cat9 | 90 | Horse9 | 90 | ||||
Cat10 | 100 | Horse10 | 100 | ||||
Cat11 | 110 | Horse11 | 110 | ||||
Cat12 | 120 | Horse12 | 120 | ||||
Cat13 | 130 | Horse13 | 130 | ||||
Cat14 | 140 | Horse14 | 140 | ||||
Cat15 | 150 | Horse15 | 150 | ||||
Cow1 | 10 | ||||||
Cow2 | 20 | ||||||
Cow3 | 30 | ||||||
Cow4 | 40 | ||||||
Cow5 | 50 | ||||||
Cow6 | 60 | ||||||
Cow7 | 70 | ||||||
Cow8 | 80 | ||||||
Cow9 | 90 | ||||||
Cow10 | 100 | ||||||
Cow11 | 110 | ||||||
Cow12 | 120 | ||||||
Cow13 | 130 | ||||||
Cow14 | 140 | ||||||
Cow15 | 150 |
If that makes sense already... this is what i was trying so far, i am just stuck in how to make the replacement word change to next one of the list of the with list. And how to paste at the end of the new list..
VBA Code:
LastRow = Range("E4").End(xlDown).Row
Set Rplc = Range("E3")
Set Wth = Range("E4:E" & LastRow)
For Each cell In Wth
Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Replace What:=Rplc, Replacement:=Wth, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A3:B32").Select
Selection.Copy
Range("H3").Select
ActiveSheet.Paste
Set Rplc = Wth
Next cell
Hope it makes sense and someone can help me with this one.
thanks in advance!