Macro find variety of text

st1

New Member
Joined
Jul 29, 2009
Messages
25
hi

i have a macro that i wish to change to search for different text. It currently searches for "mc20" but i want to be able to specify a variety of text like say "Mc542,"Mc13" can anyone help?
I have played around trying to use array and things to know avail. I am a excel novice any input would be gratefully received.

please see code below

Code:
Sheets("5 Axis List").Select
Range("A5:e100").Select
    Selection.ClearContents
    Range("g5:g100").Select
    Selection.ClearContents
 Dim r As Long
    Dim Cell As Range
    Dim FirstAddress As String
    r = 5
    
    
    With Worksheets("SHOP LOAD").Columns("f")
       Set Cell = .Find(what:="[U]MC20[/U]", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows)
       If Not Cell Is Nothing Then
            FirstAddress = Cell.Address
            Do
               With Worksheets("5 Axis List")
                    .Range("C" & r).Value = Worksheets("SHOP LOAD").Cells(Cell.Row, 3).Value
                    .Range("B" & r).Value = Worksheets("SHOP LOAD").Cells(Cell.Row, 2).Value
                    .Range("A" & r).Value = Worksheets("SHOP LOAD").Cells(Cell.Row, 1).Value
                    .Range("d" & r).Value = Worksheets("SHOP LOAD").Cells(Cell.Row, 4).Value
                    .Range("E" & r).Value = Worksheets("SHOP LOAD").Cells(Cell.Row, 5).Value
                    .Range("g" & r).Value = Worksheets("SHOP LOAD").Cells(Cell.Row, 6).Value
                    .Range("o" & r).Value = Worksheets("SHOP LOAD").Cells(Cell.Row, 9).Value
             End With
                r = r + 1
                Set Cell = .FindNext(Cell)
          Loop While Cell.Address <> FirstAddress
        End If
    End With


Application.ScreenUpdating = True
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,196,073
Messages
6,013,270
Members
441,759
Latest member
ab_

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