Refer to first cell in range
Look for .cells(1) in the previous post.
art wrote:
What about refering to the first cell in the range? How can I refer to that?
Please help.
"Dave Peterson" wrote:
Maybe you can let them select whatever they want and then just limit the
selection to a single cell or single column.
Option Explicit
Private Sub CommandButton1_Click()
Dim TestRng As Range
Dim SingleCell As Range
Dim SingleColumn As Range
Set TestRng = Nothing
On Error Resume Next
Set TestRng = Application.Range(Me.RefEdit1.Value)
On Error GoTo 0
If TestRng Is Nothing Then
'no range selected, what should happen
MsgBox "Not a range!"
Else
Set SingleCell = TestRng.Cells(1)
Set SingleColumn = TestRng.Columns(1)
MsgBox SingleCell.Address & vbLf & SingleColumn.Address
End If
Unload Me '???
End Sub
But you could do some validation...
if testrng.areas.count 1 _
or testrng.columns.count 1 _
or testrng.cells.count 1 _
or testrng.row < 12 _
or testrng.column < 17 then
You can mix or match what you want to check.
art wrote:
Hello:
I have a userform with a refedit. I need to refer to the first cell (top) in
the rnage how can I refer to it?
Also How can I retrict the user to select only 1 column at a time, meaning
he can select a range from column C from row 1 to row 10000... but he cannot
also select C1 to D5?
Thanks
--
Dave Peterson
--
Dave Peterson
|