Assuming your user enters a range with multiple columns and rows, you can perform the following check to exit the function if that is what you had in mind in the question ...
Function myFunction(ByRef myCell as Range) as SomeDataType_of_your_choice Dim numRow as Long, numCol as Long numRow = myCell.Columns.Count numCol = myCell.Rows.Count If numRow > 1 or numCol > 1 Then MsgBox "Only one cell is accepted" Exit Function Else '-- do other stuff you want to do here End If End Function
bonCodigo
source share