Do
strNewListItemName = InputBox("Please enter an account name.", "Enter new account name", SampleName)
If strNewListItemName = "New Account name." Then
MsgBox ("You need to change the default account input")
ElseIf StrPtr(strNewListItemName) = 0 Then
Exit Sub
ElseIf strNewListItemName = "" Then
MsgBox ("Can not be blank or use the default input text")
ElseIf Len(strNewListItemName) > 30 Then
MSG1 = MsgBox("Your account name exceeded 30 characters, try shortening the account name.", vbOKOnly + 48, "Warning, Error")
End If
Loop Until Len(strNewListItemName) < 31 And Not strNewListItemName = "New Account name." And Not strNewListItemName = ""
Sub test()
Dim name As String
lastrow = Sheet1.Range("A65536").End(xlUp).Row + 1
name = InputBox("Enter your name")
For i = 1 To Len(name)
If VBA.Asc(VBA.Mid(name, i, 1)) >= 65 And VBA.Asc(VBA.Mid(name, i, 1)) <= 90 Or _
VBA.Asc(VBA.Mid(name, i, 1)) >= 97 And VBA.Asc(VBA.Mid(name, i, 1)) <= 122 Or _
IsNumeric(name) Then Sheet1.Cells(lastrow, 1).Value = name
Else
MsgBox "Only text or only numbers can be entered", vbCritical
Exit For
End If
Next
End Sub
Do
300
strNewListItemName = InputBox("Please enter an account name.", "Enter new account name", SampleName)
For i = 1 To Len(strNewListItemName)
If VBA.Asc(VBA.Mid(strNewListItemName, i, 1)) >= 65 And VBA.Asc(VBA.Mid(strNewListItemName, i, 1)) <= 90 Or VBA.Asc(VBA.Mid(strNewListItemName, i, 1)) >= 97 And VBA.Asc(VBA.Mid(strNewListItemName, i, 1)) <= 122 Then
Else
MsgBox "Input can only be text or numbers, try again.", vbCritical
GoTo 300
End If
Next
If strNewListItemName = "New Account name." Then
MsgBox ("You need to change the default account input")
ElseIf StrPtr(strNewListItemName) = 0 Then
Exit Sub
ElseIf strNewListItemName = "" Then
MsgBox ("Input can not be blank or it cannot use the default input text")
ElseIf Len(strNewListItemName) > 30 Then
MSG1 = MsgBox("Your account name exceeded 30 characters, try shortening the account name.", vbOKOnly + 48, "Warning, Error")
End If
Loop Until Len(strNewListItemName) < 31 And Not strNewListItemName = "New Account name." And Not strNewListItemName = ""
valid = false
Do While valid = false
strNewListItemName = InputBox("Please enter an account name.", "Enter new account name", SampleName)
For i = 1 To Len(strNewListItemName)
If VBA.Asc(VBA.Mid(strNewListItemName, i, 1)) >= 65 And _
VBA.Asc(VBA.Mid(strNewListItemName, i, 1)) <= 90 Or _
VBA.Asc(VBA.Mid(strNewListItemName, i, 1)) >= 97 And _
VBA.Asc(VBA.Mid(strNewListItemName, i, 1)) <= 122 Then valid = true
Else
MsgBox "Input can only be text or numbers, try again.", vbCritical
End If
Loop
If VBA.Asc(VBA.Mid(strNewListItemName, i, 1)) >= 65 And _
VBA.Asc(VBA.Mid(strNewListItemName, i, 1)) <= 90 Or _
VBA.Asc(VBA.Mid(strNewListItemName, i, 1)) >= 97 And _
VBA.Asc(VBA.Mid(strNewListItemName, i, 1)) <= 122 Then
Else
MsgBox "Input can only be text or numbers, try again.", vbCritical
GoTo 300
End If
There is nothing "special" with a string having a forward slash.