A simple macro for a simple Array...?

Dreamteam

New Member
Joined
Feb 22, 2018
Messages
28
Office Version
  1. 365
Platform
  1. Windows
Hi all

Below is a list of data in col A of football results. The data pattern is consistent - Date of match; Home team; Score (home team first) and finally Away team. And then it moves onto the next result. I have been trying to simply move it over into a more readable format - starting with cell C2. I thought this would be easy but I am cannot seem to do this. I thought initially that I would put col A into an array and then move it to the table - but to no avail.

Any help would be much apprecitated.

Many thanks

Dt

Football - probabilities.xlsm
ABCDEFG
219.05. 16:00DateHome ClubHome GoalsAway GoalsAway Club
3Chelsea19.05. 16:00Chelsea21Everton
42 - 119.05. 16:00Liverpool10QPR
5Everton19.05. 16:00Manchester City23Norwich
619.05. 16:0019.05. 16:00Newcastle01Arsenal
7Liverpool19.05. 16:00Southampton11Stoke
81 - 0
9QPR
1019.05. 16:00
11Manchester City
122 - 3
13Norwich
1419.05. 16:00
15Newcastle
160 - 1
17Arsenal
1819.05. 16:00
19Southampton
201 - 1
21Stoke
Sheet5
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Here's one way :
VBA Code:
Sub v()
Dim rng As Range, i%
Set rng = Range([A1], [A2].End(4))
For i = 1 To rng.Count Step 4
   Cells(Rows.Count, "C").End(3)(2).Resize(, 4).Value = Application.Transpose(rng(i).Resize(4))
Next
End Sub
 
Upvote 0
Set rng = Range([A1], [A2].End(4))

Should be :

Set rng = Range([A2], [A2].End(4))
 
Upvote 0
Hi Footoo,

Many thanks for this.

This is definitely good enough for what I want to do.

:~)
 
Upvote 0
Please try at C2

=IF(COUNTIF(C$1,"*goals"),--MID(INDEX($A:$A,ROWS(C$2:C2)*4-1),COUNTIF($C$1:C$1,"*goals")*4-3,2),INDEX($A:$A,(ROWS(C$2:C2)-1)*4+COLUMNS($C2:C2)-(COLUMNS($C2:C2)>3)))
 
Upvote 0
Hi Bo_Ry

Sorry I missed this - um, no this does not do what I was hoping for...

Dt
 
Upvote 0
I hope I am allowed to do this... I think so...

The solution above is not really what I was hoping for - as I still need to split out the scores into Home and Away...

Does anyone else have any other solutions. As I mentioned at the beginning - I was assuming this could be stored in an array and then called upon to split out into the required columns. My brain says this should be straight forward but maybe not...

Any insights would be much apprecitated

dt
 
Upvote 0
Book1
ABCDEFG
119.05. 16:00DateHome ClubHome GoalsAway GoalsAway Club
2Chelsea19.05. 16:00Chelsea21Everton
32 - 119.05. 16:00Liverpool10QPR
4Everton19.05. 16:00Manchester City23Norwich
519.05. 16:0019.05. 16:00Newcastle01Arsenal
6Liverpool19.05. 16:00Southampton11Stoke
71 - 0
8QPR
919.05. 16:00
10Manchester City
112 - 3
12Norwich
1319.05. 16:00
14Newcastle
150 - 1
16Arsenal
1719.05. 16:00
18Southampton
191 - 1
20Stoke
Sheet1
Cell Formulas
RangeFormula
C2:G6C2=IF(COUNTIF(C$1,"*goals"),--MID(INDEX($A:$A,ROWS(C$2:C2)*4-1),COUNTIF($C$1:C$1,"*goals")*4-3,2),INDEX($A:$A,(ROWS(C$2:C2)-1)*4+COLUMNS($C2:C2)-(COLUMNS($C2:C2)>3)))


If this is not what you want, then I have no idea at all.
 
Upvote 0
Bo_Ry...

This is perfect...!

I'm not quite sure what I did when it did not work.

Again... thanks for your time and your solution

Dt
 
Upvote 0
VBA Code:
Sub v()
Dim rng As Range, i%
Set rng = Range([A1], [A2].End(4))
For i = 1 To rng.Count Step 4
    Cells(Rows.Count, "C").End(3)(2).Resize(, 3).Value = Application.Transpose(rng(i).Resize(3))
    Cells(Rows.Count, "G").End(3)(2).Value = rng(i + 3)
Next
Range("E2:E" & Cells(Rows.Count, "E").End(3).Row).TextToColumns Destination:=Range("E2"), DataType:=xlDelimited, _
    Other:=True, OtherChar:="-", FieldInfo:=Array(Array(1, 1), Array(2, 1))
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,893
Members
449,194
Latest member
JayEggleton

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top