0

I wrote this code which is part of a Select Case statement. It searches for a term variable (find_Element) and then pastes it to another worksheet and another cell.

Case 1
        find_Element = "Finished goods, net"

                For k = 3 To last_WS
                    With Sheets(k).Range("1:200")
                    sh_Name = Worksheets(k).Name
                    'sh_Name = Replace(sh_Name, "_", " ")
                    Set pointer_to_Element = .Find(find_Element, _
                        .Cells(.Cells.Count), xlValues, xlWhole, xlByRows, _
                        xlNext, False)
                    pointer_Int_Row = CInt(pointer_to_Element.Row)

                    Worksheets(k).Cells(pointer_Int_Row, lock_Array(k)).Copy
                    Worksheets("EXTRACTIONS").Range("B12").Offset(, q).PasteSpecial xlPasteValues
                    Worksheets("EXTRACTIONS").Range("B11").Offset(, q).Value = sh_Name
                    q = q + 1
                End With
            Next k

q = 1

However many elements like this one have micro-variations in naming that render my code useless.

For example sometimes the worksheet instead of having Finished goods, net in the cell we are looking for it has Finished goods or Finished goods,....

How can i adjust my code to enable him to find the element and not be derailed by such micromodifications in the reports i am receiving?

Andy G
  • 19,232
  • 5
  • 47
  • 69
Codo
  • 271
  • 3
  • 10
  • 24

1 Answers1

1

Change xlWhole to xlPart and search for "finished goods", case insensitively.

Andy G
  • 19,232
  • 5
  • 47
  • 69