leeksleeks
Board Regular
- Joined
- Oct 31, 2013
- Messages
- 96
Hi,
I currently have a sports results worksheet that searches through the results and pastes them into a worksheet with the same name (first 3 letters of the team). However i would now like it to paste these results in the next available blank cell on each worksheet and not always in Cell A3. Whilst I know what part of the code sends it to cell A3, I don't know how to make it so that the results are updated in the next blank cell. This was a code that was written by an ex work colleague of mine that I dont fully understand so if someone can please explain the procedures it is running through and how I could change it that would be great. Here is the code:
Dim home As String
Dim away As String
Dim name As String
Dim index As Integer
For k = 2 To 13 'number of teams worksheets
index = 0
For i = 1 To 500
home = Trim(Cells(i, 2).Value)
away = Trim(Cells(i, 4).Value)
name = Trim(Sheets(k).name)
If home = name Or away = name Then
For j = 1 To 5
Sheets(k).Cells(3 + index, j) = Cells(i, j)
Next j
index = index + 1
End If
Next i
Next k
End Sub
Any help would be greatly appreciated.
I currently have a sports results worksheet that searches through the results and pastes them into a worksheet with the same name (first 3 letters of the team). However i would now like it to paste these results in the next available blank cell on each worksheet and not always in Cell A3. Whilst I know what part of the code sends it to cell A3, I don't know how to make it so that the results are updated in the next blank cell. This was a code that was written by an ex work colleague of mine that I dont fully understand so if someone can please explain the procedures it is running through and how I could change it that would be great. Here is the code:
Dim home As String
Dim away As String
Dim name As String
Dim index As Integer
For k = 2 To 13 'number of teams worksheets
index = 0
For i = 1 To 500
home = Trim(Cells(i, 2).Value)
away = Trim(Cells(i, 4).Value)
name = Trim(Sheets(k).name)
If home = name Or away = name Then
For j = 1 To 5
Sheets(k).Cells(3 + index, j) = Cells(i, j)
Next j
index = index + 1
End If
Next i
Next k
End Sub
Any help would be greatly appreciated.