How to check numeric?

daniel50096230

Board Regular
Joined
May 2, 2008
Messages
163
Hi,I would like to validate that the row that choose by the user is end with 3...Means 3,13,23,33...How can I validate it?
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Validate in what way? -- Is this a macro? A formula?

= Right(RowValue,1) = 3

This would work in VBA or as a spreadsheet formula. You can use Row() to get the row value, i.e.:
=Right(Row(A3),1) = 3 | True
=Right(Row(A13),1) = 3 | True
=Right(Row(A20),1) = 3 | False

AB
 
Upvote 0
I would like to validate it using macro...If the user choose the row not end with 3,then a message box will be prompt.
 
Upvote 0
In what way is the user choosing? Is this using the input box?

In short,
Code:
Sub test()
Dim r As Range

Set r = Application.InputBox(Prompt:="Pick a cell.", Type:=8)

If r.Rows.Count = 1 Then
    If Right(r.Row, 1) <> 3 Then
        MsgBox "Bad row!!"
    End If
Else
    MsgBox "You picked more than one row!!"
End If

End Sub
 
Upvote 0
Good,your code is excellent to my system...thanks.........But in the input box,if the user click Cancel without choosing any row,there will be error,may i know how to avoid this error?
 
Upvote 0
Hi, in a hurry here but I think this will help out (it's my "canned" routine):

Code:
Sub InputBoxToSelectRange()
Dim r As Range

On Error GoTo Handler
Set r = Application.InputBox("Select the Range to Process", Type:=8)
On Error GoTo 0

~~Proceed with the rest of your routine here.

Handler:
MsgBox "You cancelled!!"
End Sub

You just use some on the spot error-handling to deal with that.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top