我试图在最后一个空格的单元格内拆分一个值。例如,我希望Abbey Road 4
分为Abbey Road
和4
我需要使用VBA,而不是公式,因为我需要删除原始列。
答案 0 :(得分:2)
查看INSTRREV以查找字符串中最后一次出现的字符串。 https://msdn.microsoft.com/en-us/library/hsxyczeb(v=vs.84).aspx
/tmp/ccwb6Fnv.o: In function `main':
myapp.c:(.text+0xa): undefined reference to `printMe_dyn'
collect2: error: ld returned 1 exit status
答案 1 :(得分:0)
这是Darren Bartrup-Cook的答案的变体...
假设单元格A2中有文本Some text with spaces
,下面将在C2中放置Some text with
,在D2中放置spaces
'Get text from A2
theText = Cells(2, 1).Value
'Get text to the left of last space
newTextLeft = Left(theText, InStrRev(theText, " ") - 1)
Cells(2, 3).Value = newTextLeft
'Get text to right of last space
newTextRight = Mid(theText, InStrRev(theText, " ") + 1)
Cells(2, 4).Value = newTextRight