HelloKhritty
New Member
- Joined
- Jan 7, 2022
- Messages
- 9
- Office Version
- 2016
- 2013
- 2011
- 2010
- Platform
- Windows
Hi,
I'm working on an autofilter in VBA and having a hard time in executing the code. so my problem is, I'd like to get all the number that has the last 2 digits same as on a cell value. for example the cell contains 51. I'd like to get 451, 551, 751,651 all that has the number 51 in it. the code was successful when i am only using the code without the wildcard. but when i am adding the asterisk, the cells are emptied when i clicked the command button. I will appreciate your help a lot. Thank you.
Sub team()
Dim val As String
val = "*" & Range("B3").Value & "*"
With Worksheets("Sheet1").Range("A7")
.AutoFilter Field:=3, Criteria1:=val, Operator:=xlFilterValues
End With
End Sub
I'm working on an autofilter in VBA and having a hard time in executing the code. so my problem is, I'd like to get all the number that has the last 2 digits same as on a cell value. for example the cell contains 51. I'd like to get 451, 551, 751,651 all that has the number 51 in it. the code was successful when i am only using the code without the wildcard. but when i am adding the asterisk, the cells are emptied when i clicked the command button. I will appreciate your help a lot. Thank you.
Sub team()
Dim val As String
val = "*" & Range("B3").Value & "*"
With Worksheets("Sheet1").Range("A7")
.AutoFilter Field:=3, Criteria1:=val, Operator:=xlFilterValues
End With
End Sub