Test for multiple rows

S

Sandy

Hi

How can I check the output from the following to ensure
that only one row has been selected

Dim rRange As Range

Set rRange = Application.InputBox(Prompt:="Please select any entry within
" _
& vbCrLf & "the row you would like to amend.", _
Title:="Select a row", Type:=8)

Thanks
Sandy
 
B

Bernie Deitrick

Sandy,

After the inputbox line, use

If rRange.Rows.Count > 1 Then
Set rRange = rRange.Rows(1)
MsgBox "I will work on only " & rRange.Address
End If

HTH,
Bernie
MS Excel MVP
 
J

Jim Cone

This uses the first row of whatever was selected...
'--
Sub Uncertain()
Dim rRange As Range

On Error Resume Next
Set rRange = Application.InputBox _
(Prompt:="Please select any entry within" & _
vbCrLf & "the row you would like to amend.", _
Title:="Select a row", Type:=8)
On Error GoTo 0

If rRange Is Nothing Then Exit Sub
Set rRange = rRange.EntireRow.Rows(1)
MsgBox "You selected row " & rRange.Row & " ", vbInformation, "Sandy"
End Sub
--
Jim Cone
Portland, Oregon USA




"Sandy"
wrote in message
Hi
How can I check the output from the following to ensure
that only one row has been selected

Dim rRange As Range
Set rRange = Application.InputBox(Prompt:="Please select any entry within " _
& vbCrLf & "the row you would like to amend.", _
Title:="Select a row", Type:=8)

Thanks
Sandy
 
B

Bernie Deitrick

Jim,

Be careful with that EntireRow since it will extend the range beyond the initial rRange (possibly).

HTH,
Bernie
MS Excel MVP
 
J

Jim Cone

Hi Bernie,
That was my intent as Sandy said: "to ensure that only one row has been selected"
But maybe the intent was... only cells in one row have been selected?
There's a solution out there somewhere. <g>
Sincerely,
Jim Cone
Portland, Oregon USA


"Bernie Deitrick"
wrote in message
Jim,
Be careful with that EntireRow since it will extend the range beyond the initial rRange (possibly).
HTH,
Bernie
MS Excel MVP
 
S

Sandy

My phraseology Jim
The intent was to ensure "only cells in one row have been selected"
However I now know how to account for the whole row too :)
Sandy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top