PDA

View Full Version : Target Specific Array Elements Group



dj44
11-09-2017, 09:53 AM
folks,

good day

how may i target the elements of the replace array

between 5 and 8




Sub Target_Array()


oSearch = Array(1, 2, 3)

oReplace = Array(A, B, C, D, E, F, G, H, i, j, K, L, M)

j=0
For i = LBound(oSearch) To UBound(oSearch)

For Each cel In ActiveSheet.Range("A1:A100").Cells

cel.Replace What:=oSearch(i), Replacement:=oReplace(i)


Next cel
Next i


End Sub



so that the result will be

F,G,H on the replace for 1,2,3


I need to set a j somewhere?

Paul_Hossler
11-09-2017, 11:04 AM
Not exactly sure about what you want to do, but I don't think you need a j





Sub Target_Array()


oSearch = Array(1, 2, 3)

oReplace = Array(A, B, C, D, E, F, G, H, i, j, K, L, M)

For i = LBound(oSearch) To UBound(oSearch)

For Each cel In ActiveSheet.Range("A1:A100").Cells

cel.Replace What:=oSearch(i), Replacement:=oReplace(I+5)


Next cel
Next i


End Sub

dj44
11-09-2017, 01:49 PM
Hello Paul,

oh yes that does make sense.

I want to replace from the 5th element onwards.

1 > E

2 > F

3 >G


my basic array replacement didint work - let me do some more experimentation