Find a cell containing specific text and make it into Table Form

edcelone

New Member
Joined
Aug 22, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi,

Would like to ask for help. I have this 1 column list below. This is what I wanted to do:
1. Find Cells containing "Best Position", then copy 1 cell above and 6 cell below as shown on Data 2 (column A).
2. Make it into Table Form as shown on Data 2 (columns B to D)

Data 1:
Book1
A
1Type
2Name
3Status
4Odds
5Payback
6Combinable
7Head
8i
9Matchups (MLF Championship 2020)
10Best position
11Id No: 46373893
12OPEN
13Jake, Daniel
141.85
15Ana, Rory
161.95
1794.93
18Opens:
1983939 939
20Suspends:
212939300 02
22Closes:
23200830 2300
24Head
25i
26Matchups (CDE Winner 2020)
27Best position
28Id No: 46373892738
29OPEN
30Night, Jason
311.8
32Ocean, Tiger
332
3494.74
35Opens:
36200824 1826
37Suspends:
38200827 1300
39Closes:
40200830 2300
41Head
42i
43Tournament Predictions (BMW Championship 2020)
44Hole in One in Round 3
45Bet Offer Id: 2222785334
46OPEN
47Yes
48n
49No
50n
51BMW Championship 2020
52n
530
54Opens:
55200824 0855
56Suspends:
57200827 1300
58Closes:
59200830 2300
60Head
61i
62Matchups (FGE Tourney)
63Best position
64Id No: 475859
65OPEN
66Harman, John
671.91
68Conners, Calley
691.91
7095.5
71Opens:
72200824 1826
73Suspends:
74200827 1300
75Closes:
76200830 2300
77Head
78i
79Matchups (FDA 2020)
80Best position
81Id No: 463738930
82OPEN
83Hatton, Harton
841.8
85Woodland, Edu
862
8794.74
88Opens:
89200824 1826
90Suspends:
91200827 1300
92Closes:
93200830 2300
94Matchups (BMW 2018)
95Best position
96Id No: 4637586
97OPEN
98Oosthuizen, Arc
991.91
100Na, Kiki
1011.91
10295.5
103Opens:
104200824 1826
105Suspends:
106200827 1300
107Closes:
108200830 2300
109Head
110i
111Predictions (BMW 2020)
112One in Round 3
113Bet Offer Id: 2222785334
114OPEN
115Yes
116n
117No
118n
119BMW 2020
120n
1210
122Opens:
123200824 0855
124Suspends:
125200827 1300
126Closes:
127200830 2300
Sheet1


Data 2:
Book1
ABCDE
1Matchups (MLF Championship 2020)Matchups (MLF Championship 2020)Best positionJake, Daniel1.85
2Best positionId No: 46373893OPENAna, Rory1.95
3Id No: 46373893Matchups (CDE Winner 2020)Best positionNight, Jason1.8
4OPENId No: 46373892738OPENOcean, Tiger2
5Jake, DanielMatchups (FGE Tourney)Best positionHarman, John1.91
61.85Id No: 475859OPENConners, Calley1.91
7Ana, RoryMatchups (FDA 2020)Best positionHatton, Harton1.8
81.95Id No: 463738930OPENWoodland, Edu2
9Matchups (CDE Winner 2020)Matchups (BMW 2018)Best positionOosthuizen, Arc1.91
10Best positionId No: 4637586OPENNa, Kiki1.91
11Id No: 46373892738
12OPEN
13Night, Jason
141.8
15Ocean, Tiger
162
17Matchups (FGE Tourney)
18Best position
19Id No: 475859
20OPEN
21Harman, John
221.91
23Conners, Calley
241.91
25Matchups (FDA 2020)
26Best position
27Id No: 463738930
28OPEN
29Hatton, Harton
301.8
31Woodland, Edu
322
33Matchups (BMW 2018)
34Best position
35Id No: 4637586
36OPEN
37Oosthuizen, Arc
381.91
39Na, Kiki
401.91
Sheet2
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Give this a try.

VBA Code:
Sub BestPosition()
  Dim a As Variant, b As Variant
  Dim i As Long, k As Long
  
  a = Range("A1", Range("A" & Rows.Count).End(xlUp)).Value
  ReDim b(1 To UBound(a), 1 To 4)
  For i = 1 To UBound(a)
    If a(i, 1) = "Best position" Then
      k = k + 2
      b(k - 1, 1) = a(i - 1, 1)
      b(k - 1, 2) = a(i, 1)
      b(k, 1) = a(i + 1, 1)
      b(k, 2) = a(i + 2, 1)
      b(k - 1, 3) = a(i + 3, 1)
      b(k - 1, 4) = a(i + 4, 1)
      b(k, 3) = a(i + 5, 1)
      b(k, 4) = a(i + 6, 1)
    End If
  Next i
  With Range("B1:E1").Resize(k)
    .Value = b
    .Columns.AutoFit
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,785
Messages
6,126,890
Members
449,347
Latest member
Macro_learner

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