0

I want to autofilter a matrix according to a word search in a specific column (the column has long texts -string-).

The macro copies the autofiltered cells and pastes them in a new book. I am finding a problem to autofilter the arrange for all words-like the key word.

E.g. I use the word "circuit" and get only one row with results but there are two additional rows with the word "circuits". If I used the word "circuits", I don't get any result.

How can I autofilter the arrange by finding a word without an exact match?

This is the relevant part of my code:

Sub Enviardatosfiltrados()
    Dim wbLibroActual As Workbook
    Dim wsHojaActual As Worksheet
    Dim RangoDatos As Range
    Dim uFila As Long
    Dim wbLibroNuevo As Workbook
    
    Set wbLibroActual = Workbooks(ThisWorkbook.Name)
    Set wsHojaActual = wbLibroActual.ActiveSheet
    
    Set RangoDatos = wsHojaActual.UsedRange
    
    RangoDatos.AutoFilter Field:=22, Criteria1:="=*" & "circuit" & "*"
    
    uFila = wsHojaActual.Range("A" & Rows.Count).End(xlUp).Row
Community
  • 1
  • 1

1 Answers1

0

You are almost there.

Just add this Operator to your definition:

RangoDatos.AutoFilter Field:=22, Criteria1:="=*" & "circuit" & "*", Operator:=xlAnd

Hint: Record macro on your Developer tab, and change your autofilter to get the right code.

Zsolt J
  • 1
  • 1