blackie42
10-16-2007, 11:12 AM
Is it possible to force a user to only 9 characters in an input box?
I have a delete sub that asks a user for a string to delete - most of which are numeric (but always 9 characters). Problem is if they only put in 4 characters and this matches some of the actual values it deletes them instead.
Sub Del_rows()
Dim Wrkst As Worksheet
Dim lLoop As Long
Dim rStart As Range
Dim vsearch As String
Application.ScreenUpdating = False
vsearch = InputBox("PLAN TO DELETE", "PLAN NUMBER ?", vbOKCancel)
If vsearch = "" Then Exit Sub
On Error Resume Next
For Each Wrkst In Worksheets
With Wrkst.UsedRange
Set rStart = .Cells(1, 1)
For lLoop = 1 To WorksheetFunction.CountIf(.Cells, vsearch)
Set rStart = .Find(What:=vsearch, After:=rStart, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows)
rStart.EntireRow.Delete
Next lLoop
End With
Next Wrkst
End Sub
thanks
I have a delete sub that asks a user for a string to delete - most of which are numeric (but always 9 characters). Problem is if they only put in 4 characters and this matches some of the actual values it deletes them instead.
Sub Del_rows()
Dim Wrkst As Worksheet
Dim lLoop As Long
Dim rStart As Range
Dim vsearch As String
Application.ScreenUpdating = False
vsearch = InputBox("PLAN TO DELETE", "PLAN NUMBER ?", vbOKCancel)
If vsearch = "" Then Exit Sub
On Error Resume Next
For Each Wrkst In Worksheets
With Wrkst.UsedRange
Set rStart = .Cells(1, 1)
For lLoop = 1 To WorksheetFunction.CountIf(.Cells, vsearch)
Set rStart = .Find(What:=vsearch, After:=rStart, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows)
rStart.EntireRow.Delete
Next lLoop
End With
Next Wrkst
End Sub
thanks