• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Divide list/Table in two

Code:
Option Explicit

Sub splitX()
    Dim lr As Long
    Dim half As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    half = lr / 2
    Range("A1:F" & half).Copy Range("H1")
    Range("A" & half + 1 & ":F" & lr).Copy Range("O1")

End Sub
 
Thanks Alan
Code:
Option Explicit

Sub splitX()
    Dim lr As Long
    Dim half As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    half = lr / 2
    Range("A1:F" & half).Copy Range("H1")
    Range("A" & half + 1 & ":F" & lr).Copy Range("O1")

End Sub
This works for an Even number of players,

This slight change works for an Odd number of players,

Range("A1:F" & half - 1).Copy Range("H1")
Range("A" & half & ":F" & lr).Copy Range("O1")

Any way to combine both ??
 
How about this:
Code:
Sub splitX()
    Dim lr As Long
    Dim half As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    half = lr / 2
    If half Mod 2 = 1 Then
    Range("A1:F" & half).Copy Range("H1")
    Range("A" & half + 1 & ":F" & lr).Copy Range("O1")
    Else:  Range("A1:F" & half - 1).Copy Range("H1")
    Range("A" & half & ":F" & lr).Copy Range("O1")
    End If
End Sub
 
Back
Top