ToExcelOrNotToExcel
New Member
- Joined
- Jan 7, 2023
- Messages
- 13
- Office Version
- 2019
- Platform
- Windows
Hi everyone I was trying to solve a problem and someone created this code for me. I have a problem though. I want to separate a 1D array into a d array. My problem is that I want the 2d array to contain only the data of one will which after which I will perform some calculations based on the data in the array and then I would like it to be cleared and do the same thing again for the next line. I will post the data, the first solution and then the second one. Please feel free to answer to either of the two because they do the same thing. I also want to be able to call the array values outside of the with statement but it is giving me an out of range error, how do I solve this?
The second solution
Betting forula 2022.xlsm | |||
---|---|---|---|
CE | |||
3 | HM9;AM17;HM30;AM31;AM50;HM60;AM75;AM86;HM96;HM104;AM110;HM126 | ||
4 | AM31,10;AM50,31;HM60,10;AM75,31;AM86;HM96;HM104,87;AM110;HM126 | ||
5 | HA60,58;AA75;AA86;HA96;HA104,76;AA110 | ||
6 | HA9;AA17;HA30,86;AA31;AA50,87;HA60,80;AA75,59;AA86;HA96,18;HA104;AA110,81;HA126 | ||
7 | HA9,37;AA17;HA30,4;AA31,22;AA50,22;HA60,32;AA86,61;HA96,72;HA126 | ||
8 | HM9;AM17,17;HM30,86;AM31;AM50;HM60;AM75;AM86,83;HM104,3;AM110,80;HM126,79 | ||
9 | HD9;AD17,46;AD75,44;AD86;HD96;HD104;AD110;HD126 | ||
10 | HD9;AD17,40;HD30;AD31;AD50;HD80,80;AD75;AD86;HD96;HD104;AD110;HD126 | ||
11 | HD9;AD17;HD30,86;AD31;AD50;HD60;AD75;AD86;HD96;HD104;AD110;HD126 | ||
12 | HA9;AA17,60;HA30,71;AA31,68;AA50,68;HA60,67;AA75,70;HA96;HA104,87;AA110,52 | ||
13 | HM9,78;AM17,44;HM30;AM31;AM50;HM60;AM75,59;AM86,7;HM104,14;AM110,10;HM126,29 | ||
14 | AD17,44;HD30;AD31;AD50;HD60;AD75,46 | ||
15 | AD17,44;HD30;AD31;AD50;HD60;AD75,40;HD96;HD104;AD110,60 | ||
16 | AD75,50;AD86;AD110,30 | ||
17 | HD9;AD17;AD60,9;HD126 | ||
18 | HGK9;AGK17;HGK30;AGK31;AGK50;HGK60;AGK75;AGK86;HGK96;HGK104;AGK110;HGK126 | ||
19 | HA30,44;AA75,31;AA86,29 | ||
20 | HD30,4 | ||
21 | HM9,53;AM17,46;HM30,19;AM50,3;HM60,23;AM75,20;HM96;HM104;AM110,38;HM126,11 | ||
22 | AA17,30;HA30,46;AA31,80;AA50,59;HA104,3;AA110,9;HA126,61 | ||
23 | |||
24 | HM9,12;AM17,3;HM30,4 | ||
Football |
Code:
Sub FillPlayerRating()
Dim cell As Range
Dim i As Long, n As Long
Dim p As Variant, arr_2d As Variant
With Range("CE3:CE24")
n = Evaluate("=SUM(LEN(" & .Address & ")-LEN(SUBSTITUTE(" & .Address & ","";"",""""))+1)")
ReDim arr_2d(1 To n, 1 To 2)
For Each cell In .Cells
For Each p In Split(cell, ";")
i = i + 1
arr_2d(i, 1) = Trim(Split(p, ",")(0))
If InStr(1, p, ",") > 0 Then arr_2d(i, 2) = Trim(Split(p, ",")(1))
Next
Next
End With
End Sub
The second solution
Code:
Sub test3()
Dim c
c = Split(Join(Application.Transpose(Range("CE3:CE24").Value), ";"), ";")
With Range("CG3").Resize(UBound(c) + 1)
.Value = Application.Transpose(c)
.TextToColumns .Cells(1), xlDelimited, Comma:=True
End With
End Sub