I am trying to create a random draw for a golf team event with teams of three, where each team consists of a low - mid - high handicap player. Now I have created the the total number of players under one tab where I sort them into handicap order low to high; then selecting the lowest third I copy and paste them into the low handicap group under tab Random in the sheet below, repeating for the mid and then the high.
In the Random sheet I have created a macro worksheet where I am trying to do a randomized draw. I have three columns with adjacent RAND columns alongside each. These are columns A - H respectively. There are 23 rows with the heading in row 1. Now after pasting the above entries as above via a button that activates a macro to paste the data into the relevant column.
Once I have all three columns occupied I then run a macro called RandomDraw which randomizes all three columns. Problem is the data is sorted in all three columns but it sorts the blank cells as well. How can I make ignore the blanks and leave the cells containing data at the top. In this instance I only have 8 names in each column but this could vary.
The macro that does this is as follows.
Sub RandomDraw()
'
' RandomDraw Macro
'
'
Calculate
Range("A1:B23").Select
ActiveWorkbook.Worksheets("Random").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Random").Sort.SortFields.Add Key:=Range("B2:B23") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Random").Sort
.SetRange Range("A1:B23")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("D1:E23").Select
ActiveWorkbook.Worksheets("Random").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Random").Sort.SortFields.Add Key:=Range("E2:E23") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Random").Sort
.SetRange Range("D1:E23")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("G1:H23").Select
ActiveWorkbook.Worksheets("Random").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Random").Sort.SortFields.Add Key:=Range("H2:H23") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Random").Sort
.SetRange Range("G1:H23")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
End Sub
Sub PasteLow()
'
' PasteLow Macro
'
'
Range("A2:A23").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("D2").Select
End Sub
Bookmarks