Dr. Demento
Well-known Member
- Joined
- Nov 2, 2010
- Messages
- 608
- Office Version
-
- 2019
- 2016
- Platform
-
- Windows
Is there an equivalent to Replace All for use within an array? The sub below accomplishes the same thing but it uses a nested loop which I was hoping to avoid. I'm using the outer loop to cycle thru the table/array with the Find/Replace terms and the inner loop to cycle thru the data; with as many as 20 find/replace terms and as few as 500 rows of data, I'm looking at 10k cycles.
Thanks y'all.
Code:
Private Sub arr_replace(rra_format As Variant, _
col_rra As Long, _
lbt_replace As String)
Dim arr_tbl As Variant
Dim i As Long, _
row_arr As Long
' ~~ Identify table that contains the Find/Replace terms
arr_tbl = ThisWorkbook.Worksheets("formatLists").ListObjects(lbt_replace).DataBodyRange.value
For i = LBound(arr_tbl, 1) To UBound(arr_tbl, 1)
For row_arr = LBound(rra_format, 1) To UBound(rra_format, 1)
rra_format(row_arr, col_rra) = Replace(rra_format(row_arr, col_rra), arr_tbl(i, 1), arr_tbl(i, 2))
Next row_arr
Next i
End Sub
Thanks y'all.