简体   繁体   中英

Excel VBA - How To Insert Value without Formula?

The formula shows on each cell after execution, is it possible not to show the formula ?

VBA code:

Set rngCell = wbk.Worksheets("TEST1").Range("C1")

  For i = 1 To 81
    rngCell.Offset(i, 0).Value = "=round((COUNTIF('T2'!C[7],RC[-2])/60),2)"
    rngCell.Offset(i, 1).Value = "=round((COUNTIF('T3'!C[6],RC[-3])/60),2)"
    rngCell.Offset(i, 2).Value = "=round((COUNTIF('T4'!C[5],RC[-4])/60),2)"
    rngCell.Offset(i, 3).Value = "=round((COUNTIF('T5'!C[4],RC[-5])/60),2)"
  Next

There are LOTS of ways to do this, Probably the simplest it to add this in after the loop:

wbk.Worksheets("TEST1").Range("C2:F82").Value =  wbk.Worksheets("TEST1").Range("C2:F82").Value

OR

wbk.Worksheets("TEST1").Range("C2:F" & i).Value =  wbk.Worksheets("TEST1").Range("C2:F" i).Value

... I hope I got the cell references right...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM