How to filter a range by first Character in a cell?

筅森魡賤 提交于 2020-01-04 06:35:54

问题


I want to filter a multipleColumnRange by column1 if a cell.Text starts with "A"

rng01.Columns(1).AutoFilter Field:=1, Criteria1:="firstCharacter = 'A'", VisibleDropDown:=False

How could I do this, pls ?


回答1:


Something like this.

The first three lines were used for my test code.

Dim rng01 As Range
Set rng01 = [a1:c10]
rng01.Parent.AutoFilterMode = False
rng01.Columns(1).AutoFilter Field:=1, Criteria1:="=A*", VisibleDropDown:=False



回答2:


The easiest way would be to create an additional column with the first character of the words in column 1:

=LEFT(A1,1)

And filter on that new column.



来源:https://stackoverflow.com/questions/12881214/how-to-filter-a-range-by-first-character-in-a-cell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!