Dim s1 As Spreadsheet
Dim s2 As Spreadsheet
Dim i As Long
Dim nv As Long
Dim last As Long
Dim VarList() As Long
Dim Values() As Double
Dim Labels As Variant
Set s1 = SelectSpreadsheetDialog(False)
If VarPtr(s1) = 0 Then End
ReDim VarList(s1.NumberOfVariables)
If SelectVariables1(s1, "Variable Selection", 1, 1, VarList, nv, "Select a variable:") = 0 Then End
s1.GetUniqueValues(VarList(1), True, Values(), Labels)
last = UBound(Values)
Set s2 = Spreadsheets.New
s2.Visible = False
s2.SetSize(last, 1)
s2.VariableName(1) = s1.VariableName(VarList(1))
s2.VariableType(1) = s1.VariableType(VarList(1))
For i = 1 To last
If Labels(1) ="" Then s2.Value(i, 1) = Values(i) 'number
If Labels(1)<>"" Then s2.Value(i, 1) = Labels(i) 'text
Next i
s2.Variable(1).AutoFit
s2.VariableHeaders(1).AutoFit
s2.Visible = True