Find/Find next in a Range xl 2003

joe.muckle

Board Regular
Joined
Oct 19, 2010
Messages
132
Hi Guru's

I have just come accros a macro which allows me to search and then find next (... I know Ctrl + F !!!!!!).

The code is below:

Code:
Sub nthmatch()
lookfor = InputBox("What is the Item number? Use * if end of number is unknown.", "Search")
If lookfor = "" Then
  End
End If
  
Flag1:
If Not Cells.Find(What:=lookfor, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False) Is Nothing Then
  
  Cells.Find(What:=lookfor, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
      :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
      False, SearchFormat:=False).Activate
  
  If MsgBox("Is this the correct Item?", vbYesNoCancel) <> vbYes Then
    GoTo Flag1
  End If
Else
  MsgBox ("The Item is not in the list")
End If
End Sub

Does any one know how to change this so that I am only looking in Columns B and C ??

Im guessing it is within this part but I cannot work out the format.

Code:
If Not Cells.Find(What:=lookfor, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False) Is Nothing Then

Thanks in advance.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try

Rich (BB code):
If Not Columns("B:C").Find(What:=lookfor, LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False) Is Nothing Then
 
Upvote 0
Sorry to be a pain, is there a way to remove the automatic cursor position from this message box? (it is automatically placed over the 'Yes' button).

Code:
If MsgBox("Is this the correct Item?", vbYesNoCancel) <> vbYes Then
    GoTo Flag1
  End If

Thanks again.
 
Upvote 0
To make it No try

Code:
If MsgBox("Is this the correct Item?", vbYesNoCancel + vbDefaultButton2) <> vbYes Then
    GoTo Flag1
End If
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,239
Members
452,898
Latest member
Capolavoro009

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top