我的数据目前的格式类似于A列,我想根据字符的类型将其拆分为多个单元格。我尝试了一些VBA和公式的变体,但没有找到解决方案。在此先感谢您的帮助!
Column A: Asking Price: $1,595,000 Gross Revenue: $1,300,000 Cash Flow: $570,000 Inventory: Included in Asking Price
分割为:
Column B: Asking Price:
Column C: $1,595,000:
Column D: Gross Revenue:
Column E: $1,300,000
Column F: Cash Flow:
Column G: $570,000
Column H: Inventory:
Column I: Included in Asking Price
我有很多类似上面的行,每行中的空格和措辞不一致。我猜想这将需要VBA解决方案。
到目前为止,我已经尝试过了:
Option Explicit
Public Function Strip(ByVal x As String, leavenums As Boolean) As
Variant
Dim y As String, z As String, n As Long
For n = 1 To Len(x)
y = Mid(x, n, 1)
If LeaveNums = False Then
If y Like "[A-Za-z ]" Then z = z & y 'False keeps Letters and
spaces only
Else
If y Like "[0-9. ]" Then z = z & y 'True keeps Numbers and decimal
points
End If
Next n
Strip = Trim(z)
End Function
然后我用了
=NUMBERVALUE(strip(A3,TRUE))
将数字分为另一个单元格,以及
=strip(A3,FALSE)
分割文字。这种解决方案的问题在于,它将所有数字组合到一个单元格中,并将所有文本组合到另一个单元格中,我需要将每个部分拆分成自己的单元格。