Hello,
I am having an issue when trying to store values from a user selected range into a data array. I want to do this so that I can pass this array into another subroutine and create a histogram.
The error given is mismatch between range and array type but don't know how to fix this.
Code:
Thanks!
I am having an issue when trying to store values from a user selected range into a data array. I want to do this so that I can pass this array into another subroutine and create a histogram.
The error given is mismatch between range and array type but don't know how to fix this.
Code:
Code:
Sub UserInput()
Dim dataRange As Range
Dim dataArray() As Variant
Dim i As Integer
Dim cell As Range
Dim row, col As Variant
Set dataRange = Application.InputBox(prompt:="Select a Range of Data", Title:="Range Collection", Type:=8)
If dataRange Is Nothing Then
dataRange = MsgBox("Invalid Range, please retry", vbOKCancel + vbQuestion)
If dataRange = vbCancel Then 'no retry
Exit Sub
Else
Run "RangeAsObject"
End If
Else
For Each row In dataRange.Rows
For Each col In dataRange.Columns
dataArray(row, col) = Cells(row, col).Value '***?????
'Store values from selection into Array
'Array will need to be passed into histogram subroutine
Next col
Next row
End If
End Sub