I had a module that applied code to clean cells of unicode and replace with a standard letter from a dictionary range, I am trying to now do that by using a 2D array (for the first time) and then reprint the new corrected array back in the original cells. I am getting the type subscript out of range at Redim line, there maybe other errors further down the code I haven't got to yet (the unicode correction code works as used previously). Thanks for your help
Sub Test2DArray()
Worksheets("Sheet1").Activate
Dim arr As Variant, xstr
arr = ActiveSheet.UsedRange
Dim unicleanRWS As Variant, unicleanCLS
For unicleanRWS = LBound(arr, 1) To UBound(arr, 1)
For unicleanCLS = 1 To ActiveSheet.UsedRange.Rows.Count
'Originally the above line was Lbound(arr,2) to ubound(arr,2)
'but I altered as I read I could not preserve both dimensions
ReDim Preserve arr(1 To UBound(arr, 1))
xstr = arr(unicleanRWS, unicleanCLS)
keepchrs = Left(xstr, 0)
For I = 1 To Len(xstr)
If (Mid(xstr, I, 2)) = "\u" Then
Readcode = (Mid(xstr, I, 6))
CorrectUnicode = Replace(Readcode, "\u", "U+")
NormalLetter = Mid(Application.WorksheetFunction.VLookup(CorrectUnicode, _
Worksheets("Unicode").Range("A1:E1000"), 5, False), 2, 1)
xstr = keepchrs & Replace(xstr, (Mid(xstr, I, 6)), LCase(NormalLetter))
xstr = UCase(Left(xstr, 1)) & Mid(xstr, 2)
End If
Next I
arr(unicleanRWS, unicleanCLS) = xstr
Next unicleanCLS
Next unicleanRWS
FirstCell = arr(0, 0).Address
FirstCell.Resize(UBound(arr, 1), UBound(arr, 2)) = arr
End Sub