返回列表 上一主題 發帖

請問該如何只將儲存格內數字部分相加並排序

請問該如何只將儲存格內數字部分相加並排序

請問該如何只將儲存格內數字部分相加並排序
如附件

TEST.rar (42.89 KB)

本帖最後由 GBKEE 於 2012-5-3 17:52 編輯

回復 1# yueh0720
  1. Option Explicit
  2. Sub Ex()
  3.     With Sheets("TEST").Range("E2:E" & Sheets("TEST").Cells(Rows.Count, "A").End(xlUp).Row)
  4.         .Cells = ""
  5.         .Cells = "= MID(RC[-3],1,LEN(rC[-3])-1 ) + MID(RC[-2],1,LEN(rC[-2])-1 )"
  6.         .SpecialCells(xlCellTypeFormulas, xlErrors) = ""
  7.         .Value = .Value
  8.         .Cells.Sort Key1:=.Cells(1), Order1:=xlAscending, Header:=xlNo
  9.     End With
  10. End Sub
複製代碼

TOP

回復 1# yueh0720
  1. Sub xx()
  2. Dim Ar()
  3. I = 0
  4. Columns("E") = ""
  5. For R = 2 To [C65536].End(xlUp).Row Step 3
  6.   ReDim Preserve Ar(I)
  7.   Ar(I) = Application.Sum(Left(Cells(R, 2), Len(Cells(R, 2)) - 1), Left(Cells(R, 3), Len(Cells(R, 3)) - 1))
  8.   I = I + 1
  9. Next R
  10. [E2].Resize(I, 1) = Application.Transpose(Ar)
  11. [E2].Resize(I, 1).Sort Key1:=[E2], Order1:=xlAscending, Header:=xlGuess
  12. [E2].Resize(I, 1).NumberFormatLocal = "0.00"
  13. End Sub
複製代碼

TOP

        靜思自在 : 【為善競爭】人生要為善競爭,分秒必爭。
返回列表 上一主題