返回列表 上一主題 發帖

EXCEL VBA 由計算說明計算金額

回復 1# ML089
  1. Sub nn()
  2. For Each b In Range([B2], [B65536].End(xlUp))
  3.   mystr = b
  4.   For Each a In Range("E:E").SpecialCells(xlCellTypeConstants)
  5.     mystr = Replace(mystr, a, "")
  6.   Next
  7.   b.Offset(, 1) = Evaluate(mystr)
  8. Next
  9. End Sub
複製代碼
學海無涯_不恥下問

TOP

回復 3# ML089
  1. Function MyCal(Mystr As String, Rng As Range) As Double
  2. For Each a In Rng
  3.   Mystr = Replace(Mystr, a, "")
  4. Next
  5. MyCal = Evaluate(Mystr)
  6. End Function
複製代碼
C2=mycal(B2,$E$2:$E$6)
學海無涯_不恥下問

TOP

回復 5# ML089
  1. Function MyCal(Mystr As String, ParamArray MyStrList()) As Double
  2. For Each a In MyStrList
  3.   Mystr = Replace(Mystr, a, "")
  4. Next
  5. MyCal = Evaluate(Mystr)
  6. End Function
複製代碼
學海無涯_不恥下問

TOP

回復 7# ML089
  1. Function MyCal(Mystr As String) As Double
  2. MyStrList=Array("斤","兩","蘋果","香蕉","沙蝦")
  3. For Each a In MyStrList
  4.   Mystr = Replace(Mystr, a, "")
  5. Next
  6. MyCal = Evaluate(Mystr)
  7. End Function
複製代碼
學海無涯_不恥下問

TOP

        靜思自在 : 心中常存善解、包容、感思、知足、惜福。
返回列表 上一主題