Subtraction between to excel column using VBScript

前端 未结 2 546
猫巷女王i
猫巷女王i 2021-01-28 01:39

Suppose I have below excel sheet,And I need to find the difference between them and result need to put back to another column:

      ColA                      Co         


        
相关标签:
2条回答
  • 2021-01-28 02:17

    You can subtract one date from the other, and then set the formatting of the cell:

    'Within the Do..While loop
    Dim cell
    Set cell = objSheet4.Cells(intRow4,11)
    cell.Value = Date2 - Date1
    cell.NumberFormat = "hh:mm:ss"
    
    0 讨论(0)
  • 2021-01-28 02:26

    using the range object, I can set the formula on all the cells within a range at once

    range("C1:C10").Formula="=B1-A1"
    

    It will also adjust the formula based on the normal copying riles for absolute addressing.

    e.g. with the above example, C10 will be =B10-A10. If I had put the formula as "=B1-$A$1" then C10 would have been =B10-$A$1

    0 讨论(0)
提交回复
热议问题