-
Yes this is very easy with VBA
try this:
[vba]Sub movedata()
Dim Baseball10 As Range
Dim Baseball8 As Range
Dim Football10 As Range
Dim Football8 As Range
With Worksheets("Players")
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
inarr = .Range(Cells(3, 1), Cells(lastrow, 6))
End With
With Worksheets("Baseball")
Set Baseball10 = .Range(.Cells(4, 1), .Cells(19, 5))
Set Baseball8 = .Range(.Cells(22, 1), .Cells(37, 5))
End With
With Worksheets("Football")
Set Football10 = .Range(.Cells(4, 1), .Cells(19, 5))
Set Football8 = .Range(.Cells(22, 1), .Cells(37, 5))
End With
b10 = 1
b8 = 1
f10 = 1
f8 = 1
For i = 1 To lastrow - 2
If inarr(i, 1) = "Baseball" Then
If inarr(i, 4) = "10" Then
For k = 1 To 5
Baseball10(b10, k) = inarr(i, 1 + k)
Next k
b10 = b10 + 1
Else
For k = 1 To 5
Baseball8(b8, k) = inarr(i, 1 + k)
Next k
b8 = b8 + 1
End If
Else
If inarr(i, 1) = "Football" Then
If inarr(i, 4) = "10" Then
For k = 1 To 5
Football10(f10, k) = inarr(i, 1 + k)
Next k
f10 = f10 + 1
Else
For k = 1 To 5
Football8(f8, k) = inarr(i, 1 + k)
Next k
f8 = f8 + 1
End If
End If
End If
Next i
End Sub
[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules