G
Guest
I am having trouble with this program and I think it is something minor...It
scans the first column in the sheet "Data" and returns unique values to be
stored in an array "PlayerNum".
Private Sub CommandButton1_Click()
Dim PlayerNum() As Variant
Dim x As Integer
Dim i As Integer
ChDir "C:\Documents and Settings\Scott Miller\My Documents\Handicap"
Workbooks.Open Filename:= _
"C:\Documents and Settings\Scott Miller\My
Documents\Handicap\Data.xls"
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Handicap.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Windows("Data.xls").Activate
ActiveWindow.Close
Windows("Handicap.xls").Activate
Sheets("Data").Select
x = 3
i = 1
PlayerNum(i).Value = Sheets("Data").Cells(2, 1).Value
Do
Sheets("Data").Cells(x, 1).Select
If ActiveCell.Value = PlayerNum(i).Value Then
x = x + 1
Else
i = i + 1
ReDim Preserve PlayerNum(i) As Variant
PlayerNum(i).Value = ActiveCell.Value
End If
Loop Until Cells(x, 1).Value = ""
End Sub
Scott Miller
University of Washington
Chemistry
scans the first column in the sheet "Data" and returns unique values to be
stored in an array "PlayerNum".
Private Sub CommandButton1_Click()
Dim PlayerNum() As Variant
Dim x As Integer
Dim i As Integer
ChDir "C:\Documents and Settings\Scott Miller\My Documents\Handicap"
Workbooks.Open Filename:= _
"C:\Documents and Settings\Scott Miller\My
Documents\Handicap\Data.xls"
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Handicap.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Windows("Data.xls").Activate
ActiveWindow.Close
Windows("Handicap.xls").Activate
Sheets("Data").Select
x = 3
i = 1
PlayerNum(i).Value = Sheets("Data").Cells(2, 1).Value
Do
Sheets("Data").Cells(x, 1).Select
If ActiveCell.Value = PlayerNum(i).Value Then
x = x + 1
Else
i = i + 1
ReDim Preserve PlayerNum(i) As Variant
PlayerNum(i).Value = ActiveCell.Value
End If
Loop Until Cells(x, 1).Value = ""
End Sub
Scott Miller
University of Washington
Chemistry