Hello,
I have Code that finds and replaces values in a comma delimited string from a list on a separate sheet
Ex
cell value = aa,bb ,cc ,dd , ee
Replace values
aa
bb = bob
cc = joe
dd
ee = frank
I get
cell value = aa, bob, joe, dd, frank
Code works fine but is slow if I have large dataset
It postback on every row, I want to post back only once
I tried changing
I get the proper values for temp2(I - 1) but the output gives only the last found replacement value
so if Joe was the last found replacement value the posted pack data looks like
Joe
Joe
Joe
.
.
.
Joe
Thanks
I have Code that finds and replaces values in a comma delimited string from a list on a separate sheet
Ex
cell value = aa,bb ,cc ,dd , ee
Replace values
aa
bb = bob
cc = joe
dd
ee = frank
I get
cell value = aa, bob, joe, dd, frank
Code works fine but is slow if I have large dataset
It postback on every row, I want to post back only once
I tried changing
Code:
Next n
wsFV.Range("A" & I).value = Mid(temp(I - 1), 3)
Next I
End Sub
Code:
Dim temp2 As Variant
ReDim temp2(1 To sLR - 1)
Next n
temp2(I - 1) = Mid(temp(I - 1), 3)
Next I
wsFV.Range("A2:A" & sLR) = temp2
End Sub
I get the proper values for temp2(I - 1) but the output gives only the last found replacement value
so if Joe was the last found replacement value the posted pack data looks like
Joe
Joe
Joe
.
.
.
Joe
Thanks
Code:
Sub eFindReplaceSPLIT_Orgs()
Dim FindValues As Variant, Replaceval As Variant, G As Variant, temp() As Variant, temp2 As Variant
Dim wsFV As Worksheet, wsRV As Worksheet
Dim sLR As Long, tLR As Long, I As Long, j As Long, n As Long, counter As Long
Set wsFV = ThisWorkbook.Worksheets("AA")
Set wsRV = ThisWorkbook.Worksheets("ZZ")
sLR = wsFV.Range("A" & wsFV.Rows.count).End(xlUp).Row
tLR = wsRV.Range("A" & wsRV.Rows.count).End(xlUp).Row
ReDim temp(1 To sLR - 1)
ReDim temp2(1 To sLR - 1)
For I = 2 To sLR
counter = 1
G = Split(wsFV.Cells(I, 1).value, ", ")
temp(I - 1) = wsFV.Cells(I, 1).value
For n = LBound(G) To UBound(G)
For j = 2 To tLR
If splitCell(wsFV.Range("A" & I), ", ", n) = wsRV.Cells(j, "A") Then
Replaceval = IIf(wsRV.Cells(j, "B").value <> vbNullString, wsRV.Cells(j, "B").value, wsRV.Cells(j, "A").value)
temp(I - 1) = IIf(counter = 1, ", " & Replaceval, temp(I - 1) & ", " & Replaceval)
'Debug.Print temp(i - 1)
counter = counter + 1
End If
Next j
Next n
wsFV.Range("A" & I).value = Mid(temp(I - 1), 3)
Next I
End Sub
Last edited: