Irregular Data Set

IdabaMalouki

New Member
Joined
Sep 10, 2024
Messages
11
Office Version
  1. 2021
Platform
  1. Windows
I have a data set I copy and paste from a website. Someone helped me write a VBA code to sort the data:

Option Explicit

VBA Code:
Sub demo()
Dim a, b
Dim i As Long, j As Long, n As Long

a = [A1].CurrentRegion
ReDim b(1 To UBound(a, 1), 1 To 7)

For i = 2 To UBound(a, 1) Step 5
    n = n + 1
    b(n, 1) = a(i, 1): b(n, 2) = a(i + 2, 1): b(n + 1, 2) = a(i + 4, 1)
   
    b(n, 3) = a(i, 2): b(n, 4) = a(i + 1, 2)
    b(n, 5) = a(i, 3): b(n, 6) = a(i + 1, 3): b(n, 7) = a(i, 4)
    n = n + 1
    b(n, 3) = a(i + 3, 2): b(n, 4) = a(i + 4, 2)
    b(n, 5) = a(i + 3, 3): b(n, 6) = a(i + 4, 3): b(n, 7) = a(i + 3, 4)
   
Next i

[N2].Resize(n, 7) = b

End Sub

Can some help write a similar VBA for the new irregular data set in this excel workbook that will organize data in column A into format of adjacent columns:

1725975748134.png


Thanks in advance
 
Last edited by a moderator:
I will leave it with Dante since he on top of it but the symbol is commonly referred to as a "Pipe" symbol and on my keyboard is above the "\".
It is often used to as a seperator to show that the text was a concatenation of 2 or more other bits of data.
Since you are online now, can I suggest you provide an image of the two 14 row items so that Dante can see what lines are being dropped off (and is it the same on both).
 
Upvote 1

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Sep 14 | 7:45pm
Kent State Golden Flashes
Tennessee Volunteers
Spread
49
-110
-49
-110
Money
Total
62.5
-110
62.5
-110
Sep 14 | 8:00pm
Rice Owls
Houston Cougars
Spread
4
-115
-4
-105
Money
158
-190
Total
44.5
-110
44.5
-110
 
Upvote 0
Sep 14 | 3:30pm
Ball State Cardinals
Miami (FL) Hurricanes
Spread
36.5
-110
-36.5
-110
Money
Total
54
-110
54
-110
Sep 14 | 3:30pm
Tulane Green Wave
Oklahoma Sooners
Spread
13.5
-110
-13.5
-110
Money
430
-600
Total
47.5
-110
47.5
-110
 
Upvote 0
Thank you, kind sir! One more thing. I would like to separate date and time. Is there a formula I can write into adjacent cell to separate "Sep 14 | 3:30pm" to extract just the 3:30pm into adjacent cell?
 
Upvote 0
1726242879360.png


You can mark with a color the rows that will always have some data. And mark with another color those that may or may not have a value.
 
Upvote 0
Upvote 0
I can't download the file.
It would be ideal if you explained here what the patterns of your data would be.
Use images to support your explanation.

I'm trying to help you make the code. But you must help me with the explanations I requested.

Or the other option is to manually insert the missing rows into your blocks and then run the macro that I provided in post #4.
😅
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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