通配符excel 2013

问题描述 投票:0回答:1

我正在使用ms excel 2013.我已经建立了与ms访问数据库的连接,我需要进行一个类似的选择,以返回一个以3个数字结尾的特定值,后跟下划线后跟字符串。该列值可以是:1 - “sample / 023_test”或2 - “ssss / ssss / re / test_test_023_tr”或3 - “sss / 0214_dg”当我执行select * from table_name where column_name like '%[0-9][0-9][0-9][_][a-z]时,它返回所有值而不是仅返回第一个示例。我不知道应该如何使用该模式。谢谢

excel access
1个回答
0
投票

使用和UDF(USer定义函数)计算要提取的特定值。然后在查询调用中,调用计算字段。

我设计的UDF在最后一个斜杠“/”之后提取最后一个字符串。

Public Function SPECIFIC_VALUE(ByVal ThisString As String) As String
Dim MyStrings() As String
MyStrings() = Split(ThisString, "/")

'the value we want is at the end of string always, so inside array MyStrings, it will be always Ubound

SPECIFIC_VALUE = MyStrings(UBound(MyStrings))
End Function

Excel中此UDF的结果:

enter image description here

您只需键入SPECIFIC_VALUE([Fieldname])即可在Access中的查询中调用此函数

记得在Access中插入模块并在那里粘贴UDF的代码

(HOW TO INSERT A MODULE)

© www.soinside.com 2019 - 2024. All rights reserved.