B
Blur
I keep getting user defined type not defined when i try to run this...
Which are the neccessary libraries which i have to add in my
references? I have added the Microsoft VB Extensibility but it does not
work.. It always break at
" Set TempDO = New DataObject "
It's supposed to place my 15 randomly selected cells on the
clipboard... how can i modify it to place the results on the worksheet
itself?
Many thanks.....
Code:
--------------------
Sub GetRandom()
Dim iRows As Integer
Dim iCols As Integer
Dim iBegRow As Integer
Dim iBegCol As Integer
Dim J As Integer
Dim sCells As String
Set TempDO = New DataObject
iRows = Selection.Rows.Count
iCols = Selection.Columns.Count
iBegRow = Selection.Row
iBegCol = Selection.Column
If iRows < 16 Or iCols > 1 Then
MsgBox "Too few rows or too many columns"
Else
Randomize Timer
sCells = ""
For J = 1 To 15
iWantRow = Int(Rnd() * iRows) + iBegRow
sCells = sCells & Cells(iWantRow, iBegCol) & vbCrLf
Next J
TempDO.SetText sCells
TempDO.PutInClipboard
End If
End Sub
Which are the neccessary libraries which i have to add in my
references? I have added the Microsoft VB Extensibility but it does not
work.. It always break at
" Set TempDO = New DataObject "
It's supposed to place my 15 randomly selected cells on the
clipboard... how can i modify it to place the results on the worksheet
itself?
Many thanks.....
Code:
--------------------
Sub GetRandom()
Dim iRows As Integer
Dim iCols As Integer
Dim iBegRow As Integer
Dim iBegCol As Integer
Dim J As Integer
Dim sCells As String
Set TempDO = New DataObject
iRows = Selection.Rows.Count
iCols = Selection.Columns.Count
iBegRow = Selection.Row
iBegCol = Selection.Column
If iRows < 16 Or iCols > 1 Then
MsgBox "Too few rows or too many columns"
Else
Randomize Timer
sCells = ""
For J = 1 To 15
iWantRow = Int(Rnd() * iRows) + iBegRow
sCells = sCells & Cells(iWantRow, iBegCol) & vbCrLf
Next J
TempDO.SetText sCells
TempDO.PutInClipboard
End If
End Sub