I have a result sheet where I want to extract the winner of races from sheet1 to sheet2. My result sheet is 50,000 lines long. See Sample for format.
I want a macro to copy the line that is 2 spaces below the word "Name" that is repeated in Col A and is the separation between the races. Copy A:E there. Put that on sheet 2 Col A as shown in the sample. Then go back to sheet 1 and find the winner of the race which will be the one with a value in column B. Copy A:I there. Go to sheet2 and put that on the same line as the previous entry starting in Col F. Repeat Thanks.
Good Luck...
I don't presume to know what I am doing, however, just like you, I too started somewhere...
One-day, One-problem at a time!!!
If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
Also....Add a comment if you like!!!!
And remember...Mark Thread as Solved...
Excel Forum Rocks!!!
Thank You very much sintek. There is a problem in that not all blocks of data have an "OP". When the code encounters that it produces an error. But they all are either a 2 or 3 letter designation.
Sub Macro8()
Dim a, Q&, i&, b, c(1 To 2), R&, j%
With Sheets("Sheet1")
Q = .Cells(Rows.Count, 1).End(xlUp).Row
a = .Range("a1:i" & Q)
End With
ReDim b(1 To Q, 1 To 14)
For i = 1 To Q
Select Case True
Case a(i, 1) = "NAME": Erase c: c(1) = 2 + i
Case IsNumeric(a(i, 2)) And Not IsEmpty(a(i, 2))
If a(i, 2) > 0 And Not IsEmpty(c(1)) Then
c(2) = i: R = 1 + R
For j = 1 To 5: b(R, j) = a(c(1), j): Next
For j = 6 To 14: b(R, j) = a(c(2), j - 5): Next
End If
End Select
Next
With Sheets("Sheet2")
.UsedRange.Delete xlShiftUp: .Activate
If R > 0 Then
.Cells(1).Resize(R, 14) = b
.Cells(1).Resize(R, 14).Columns(14).NumberFormat = "0%"
.Cells(1).Resize(R, 14).Columns.AutoFit
End If
End With
End Sub
You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.
Bookmarks