Reputation: 13
I'm looking for way to validate my input in Macro, I want my input to be restricted to XXXXXX-XXX (eg. 465824-456). This is the code I've tried (adapted from recording macro in data validation):
Lot = Application.InputBox(prompt:="Enter Lot ID to be put into Storage :", Type:=0)
If Lot = "=AND(ISNUMBER(LEFT(Lot,6)+0),MID(Lot,7,1)=""-"",ISNUMBER(RIGHT(Lot,3)+0))" Then
But it doesn't work...
Upvotes: 1
Views: 650
Reputation: 1772
You can use "Like" Statement
If Lot Like "[0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9]" Then
Upvotes: 1