I have a situation where I need the user to select one row - just one. I am using the inputbox type 8 to allow the user to select the range, then I test to see if they selected more than one row. However, it seems when they select only one row, or even just one cell, it returns a range of rows. Can anyone help me find a better way to do this?
Excel 2003 Prof.
-JTBorton
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]
Excel 2003 Prof.
Code:
Dim rngSource As Range
Dim Catch As String
Dim Row As Integer
Dim Response As Integer
GetCell:
On Error Resume Next
Set rngSource = Nothing 'Clear the rang incase the user was redirected here and now wishes to cancel
Set rngSource = Application.InputBox(prompt:="Please select the cell that contains the name of the product you wish to remove.", Title:=strTitle, Type:=8)
If rngSource Is Nothing Then
Exit Sub 'user selected cancel
End If
On Error GoTo 0
If Not rngSource.End(xlDown).Row = rngSource.End(xlUp).Row Then
Response = MsgBox(prompt:="Please select a cell from only one row, not a range of cells.", Buttons:=vbExclamation + vbOKCancel, Title:=strTitle)
If Not Response = vbOK Then
Exit Sub
Else
GoTo GetCell
End If
End If
Row = rngSource.End(xlDown).Row
-JTBorton
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]