first time as a user here and begginer at VBA, so please be pattient.
I've got a list I wanna filter using VBA that has both numbers and strings (some of them containing numbers as part of an ID) in the column I'm ussing to apply the filter. If the filterValue is a number or a digit, I wanna be able to find it within the numbers or strings in the column. For example, if three cells have the values "3231" (as a number), "MN23" and "AR234IT" (as two strings), I should get the three of them with filterValue=23 (also with 2 or 3).
If I use "" & filterValue & "" as Criteria1, it works for the strings but it doesn't return the rows that contain number formatted cells in the filtered column. I solved it by adding ' to number cells (turning them to text format), saving their original format indicator in an array, filtering by "" & filterValue & "" and then removing the ' from every string cell that was originally a number.
Here's the code:
rowCount = filteredRegion.Rows.Count
ReDim isNumberArray(1 To rowCount) As Boolean
For i = 1 To rowCount
If Application.WorksheetFunction.IsNumber(filteredRegion(i, 3)) And filteredRegion(i, 3) <> "" Then
filteredRegion(i, 3) = "'" & (filteredRegion(i, 3))
isNumberArray(i) = True
Else
isNumberArray(i) = False
End If
Next i
filteredRegion.AutoFilter Field:=3, Criteria1:="*" & filterValue & "*"
For i = 1 To rowCount
If IsNumeric(filteredRegion(i, 3)) And filteredRegion(i, 3) <> "" And numberArray(i) Then
filteredRegion(i, 3) = CDbl(filteredRegion(i, 3))
End If
Next i
This works. I get rows filtered out that have the filterValue somewhere within them, wheter they have numeric or text content, and I keep their original format after the VBA call.
But, besides being totally awful and inefficient, it works as long as the cells edited don't have a formula that returns a number. If they do, the formula gets erased and I just get its value back. I guess I could save the formula and retrieve it but still sounds awful. Besides, I have array Formulas in one column so it would get pretty nasty. Can someone help me out? Is there a way in which I don't edit the cells at all?

This snippet hide all rows which contains in part a defined text in a specific column:
To unhide them:
filteredrange.Rows.Hidden = False