如何LastIndexOf()在 VBA 中拆分字符串
我有一个可以有这些值的字符串
Dim input As String
input = "customName_D3"
input = "Custom_Name_D3"
input = "my_Custom_Name_D3"
Run Code Online (Sandbox Code Playgroud)
就像它可以有很多"_",但最后"_"它包含单元格名称我想拆分这个字符串以获得单元格名称和其他剩余部分作为两个不同的字符串,例如
cellName = D3
remainingString = my_custom_Name
Run Code Online (Sandbox Code Playgroud)
Jea*_*ett 11
Dim strInput As String
Dim strName As String
Dim strCellAddress As String
Dim iSplit As Integer
strInput = "my_Custom_Name_D3"
iSplit = InStrRev(strInput, "_")
strName = Left(strInput, iSplit - 1)
strCellAddress = Mid(strInput, iSplit + 1)
MsgBox "Name: " & vbTab & strName & vbCrLf & "Cell: " & vbTab & strCellAddress
Run Code Online (Sandbox Code Playgroud)