如何查找在一个单元格中分隔的逗号?
How to vlookup comma separated in one cell?
我有工作表
我要填写G栏
我不知道如何解决这个问题
我想要什么:
。如果 F 列填充为黑色,则 G 列填充为 S
.如果 F 列填充为 yellow ,则 G 列填充为 M
.如果F列用红色填充,那么G列用XL
填充
我用的是office 2010
替换分隔符 (UDF)
- 在
Visual Basic Editor
中复制以下代码到标准模块中:
Option Explicit
Function ReplaceDelimited( _
ByVal SearchString As String, _
ByVal ReadSubStrings As String, _
ByVal WriteSubStrings As String, _
Optional ByVal Delimiter As String = ",") _
As String
On Error GoTo ClearError
Dim Rss() As String: Rss = Split(ReadSubStrings, Delimiter)
Dim mIndex As Variant: mIndex = Application.Match(SearchString, Rss, 0)
If IsNumeric(mIndex) Then
ReplaceDelimited = Split(WriteSubStrings, Delimiter)(mIndex - 1)
End If
ProcExit:
Exit Function
ClearError:
Resume ProcExit
End Function
在 Excel
中,对于这种特殊情况,在单元格 G2
中使用以下公式:
=ReplaceDelimited(F2,C2,D2)
我有工作表
我要填写G栏
我不知道如何解决这个问题
我想要什么:
。如果 F 列填充为黑色,则 G 列填充为 S
.如果 F 列填充为 yellow ,则 G 列填充为 M
.如果F列用红色填充,那么G列用XL
我用的是office 2010
替换分隔符 (UDF)
- 在
Visual Basic Editor
中复制以下代码到标准模块中:
Option Explicit
Function ReplaceDelimited( _
ByVal SearchString As String, _
ByVal ReadSubStrings As String, _
ByVal WriteSubStrings As String, _
Optional ByVal Delimiter As String = ",") _
As String
On Error GoTo ClearError
Dim Rss() As String: Rss = Split(ReadSubStrings, Delimiter)
Dim mIndex As Variant: mIndex = Application.Match(SearchString, Rss, 0)
If IsNumeric(mIndex) Then
ReplaceDelimited = Split(WriteSubStrings, Delimiter)(mIndex - 1)
End If
ProcExit:
Exit Function
ClearError:
Resume ProcExit
End Function
在
Excel
中,对于这种特殊情况,在单元格G2
中使用以下公式:=ReplaceDelimited(F2,C2,D2)