Hi Dave,
This is the final version of your code which I have in my system and it
works fine with a slight hitch.
It takes about 45 seconds to display the first record...I have tested
it with a sheet where there are no repetitions of numbers also...but
still it takes about 35+ seconds to display the record.
Can you guess what is making it to run so slow...May be you can give up
a booster...
Option Explicit
Sub testme()
Dim myRng As Range
Dim myCell As Range
Dim wks As Worksheet
Dim StartVal As Long
Dim EndVal As Long
Dim TempVal As Long
Dim iCtr As Long
Dim myPfx As String
StartVal = CLng(Application.InputBox(prompt:="Start with", _
Default:=1, Type:=1))
If StartVal = 0 Then
Exit Sub
End If
EndVal = CLng(Application.InputBox(prompt:="End with", _
Default:=StartVal + 1, Type:=1))
If EndVal = 0 Then
Exit Sub
End If
If EndVal < StartVal Then
TempVal = StartVal
StartVal = EndVal
EndVal = TempVal
End If
Set wks = ActiveSheet
Select Case LCase(wks.Name)
Case Is = "pc details"
Set myRng = Worksheets("pc").Range("data")
Case Is = "printer form "
Set myRng = Worksheets("printer").Range("data")
Case Is = "monitor form"
Set myRng = Worksheets("monitor").Range("data")
Case Is = "switch form"
Set myRng = Worksheets("switch").Range("data")
Case Is = "router form"
Set myRng = Worksheets("router").Range("data")
Case Is = "firewall form"
Set myRng = Worksheets("firewall").Range("data")
Case Is = "modem form"
Set myRng = Worksheets("modem").Range("data")
Case Is = "scanner form"
Set myRng = Worksheets("scanner").Range("data")
Case Else:
MsgBox "design error with worksheet: " & wks.Name
Exit Sub
End Select
'xxx???yyyyy
myPfx = InputBox(prompt:="what's the prefix")
If Trim(myPfx) = "" Then
Exit Sub
End If
myPfx = Left(myPfx & Space(3), 3) 'pad it with trailing spaces if
required.
For Each myCell In myRng.Cells
If LCase(myCell.Value) Like LCase(myPfx) & "*" Then
If IsNumeric(Mid(myCell.Value, 4, 3)) Then
If StartVal <= Val(Mid(myCell.Value, 4, 3)) _
And EndVal >= Val(Mid(myCell.Value, 4, 3)) Then
wks.Range("ID").Value = myCell.Value
Application.Calculate 'just in case
wks.Range("PRINTAREA").PrintOut preview:=True
End If
End If
End If
Next myCell
End Sub
Thanks for your help and all the support
You were really helpful and caring.
Rashid Khan