2017-04-10 75 views

回答

2

CTR + H和变化迹象-成任何独特像@然后更换+@以同样的方式。

[email protected]@1000使用后: Data/Text to columns/Delimited/Other和类型@

您可以录制宏有它的自动化。

+0

我不知道这个按钮。它的工作原理,但是,你必须先将等号(=)替换为无。否则,你会得到一个错误,因为公式将是无效的。 – z32a7ul

+0

谢谢,先生,它对我来说完美无缺。Thums起来显示出路。 –

+0

您可以通过将'-'更改为'@ -'来轻松保留号码前的数字。 –

0

这个子可以做到这一点:

Public Sub SplitSum(rngInput As Range, rngOutputStart As Range) 
    Dim varParts As Variant: varParts = Split(Replace(Replace(Mid(rngInput.Formula, 2), "-", "|"), "+", "|"), "|") 
    Dim c As Long: For c = LBound(varParts) To UBound(varParts) 
     rngOutputStart.offset(0, c - LBound(varParts)).Value = CDbl(varParts(c)) 
    Next c 
End Sub 

您可以使用它像这样:

SplitSum ActiveCell, ActiveCell.Offset(0, 1) 
+0

谢谢先生的帮助。然而,使用上面给出的解决方案,我的工作很容易。 –

0

此功能将您的数字之前保留的迹象,并已白白地写着,以便允许你如果需要,可以轻松访问以进一步调整。

Sub SumsToColumns(Rng As Range) 

    Dim RngVal As String 
    Dim Vals() As String 
    Dim n As Integer 

    RngVal = Trim(Rng.Cells(1).Formula) 
    If Len(RngVal) Then 
     RngVal = Mid(Replace(RngVal, "+ ", "+"), 2) 
     RngVal = Replace(RngVal, " +", " +") 
     RngVal = Replace(RngVal, "- ", "-") 
     RngVal = Replace(RngVal, "-", " -") 

     Do 
      n = Len(RngVal) 
      RngVal = Replace(RngVal, " ", " ") 
     Loop While Len(RngVal) < n 

     Vals = Split(RngVal) 
     For n = 0 To UBound(Vals) 
      With Rng 
       .Worksheet.Cells(.Row, .Column + n + 2).Value = Vals(n) 
      End With 
     Next n 
    End If 
End Sub 

你可以调用这个函数,像这样的行: -

SumsToColumns(Range("G13")) 

其中“G13”是你可能会从通过一列中的所有单元格循环一个简单的程序提取范围。请注意代码中的以下行。

.Worksheet.Cells(.Row, .Column + n + 2).Value 

它指定结果应该在相同的工作表被写为其中该范围(“G13”)从取,在同一行中(13在这种情况下),并开始2列到右边,在这种情况下“G”+ 2列=“I”。您可以将“2”修改为您可能需要的任何偏移量。结果将被分割成与G13中的单独数字一样多的列。

+0

谢谢先生的帮助。然而,使用上面给出的解决方案,我的工作很容易。 –

相关问题