ToExcelOrNotToExcel
New Member
- Joined
- Jan 7, 2023
- Messages
- 13
- Office Version
- 2019
- Platform
- Windows
Hello everyone I hav somee code which shold work but it is returning an error code 9 and I have no idea why. It's supposed to loop through a range of cells with strings that look like this: "AM17, 12: ;HM2; AM40; AM45, 13". I'm sure the code works but I don't understand how to solve this error.
Code:
Option Explicit
Sub FillPlayerRating()
Dim rng As Range, cell As Range
Dim ArrayCount As Integer
Dim i As Long
Set rng = Range("CE3:CE24")
Dim size_1d As Integer
For Each cell In rng
Dim arr_1d() As String
arr_1d = Split(cell.Value, ";")
size_1d = UBound(arr_1d) - LBound(arr_1d)
Dim arr_2d() As String
ReDim arr_2d(size_1d, 1) As String
For i = 0 To size_1d
Dim temp() As String
temp = Split(arr_1d(i), ",")
Dim size_temp As Integer
size_temp = UBound(temp) - LBound(temp) + 1
If size_temp = 1 Then
arr_2d(i, 0) = Trim(temp(0))
ElseIf size_temp = 2 Then
arr_2d(i, 0) = Trim(temp(0))
arr_2d(i, 0) = Trim(temp(1))
End If
Next i
' Range("CS20").Value = arr()
Next cell
End Sub