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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,836
Office Version
  1. 2019
Platform
  1. Windows
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

daniel50096230

Board Regular
Joined
May 2, 2008
Messages
163
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

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,836
Office Version
  1. 2019
Platform
  1. Windows
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

daniel50096230

Board Regular
Joined
May 2, 2008
Messages
163
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

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,836
Office Version
  1. 2019
Platform
  1. Windows
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,191,587
Messages
5,987,508
Members
440,098
Latest member
MickyMouse123

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
Top