View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ron[_6_] Ron[_6_] is offline
external usenet poster
 
Posts: 48
Default Cancel (Dismiss) Input Box

Hello all,
The code below works fine except for, if user wants to cancel before
all of the seleciton has been checked. With this code I do not have a
way for the user to back out or cancel out of the Input Box process.
Any assistance is greatly appreciated. Thank you, Ron


Sub ValidateDataN()

'validate values in a column
Range("e12").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Offset(0, 9).Select
Set Rng = Selection
FirstRow = Rng.Row
LastRow = Rng.Rows(Rng.Rows.Count).Row
col = "n"
'loop thru col n of database, but skip first row with headings
For i = FirstRow To LastRow
FixColumnN
Next i

End Sub

Private Sub FixColumnN()
Dim x As Integer, OK As Boolean
OK = True
'check to ensure six digits entered
If Len(Range("a1")(i, col).Value) < 6 Then
OK = False
End If

If OK = False Then
'Enter a new value in Column B
Range("a1")(i, col).Select
Range("a1")(i, col) = InputBox("Enter a 6 digit value")

'Range("a1")(i, col).Value = vbNullString
123 FixColumnN
End If

Rng.NumberFormat = "@"

End Sub