好吧,我有一组具有某些值(以分钟为单位)的单元格,我想将它们转换为小时,问题是这些值会不断更新,因此我需要将该列的最后一行作为变体。
我编写了这段代码,但是问题出在xldown上,我似乎忽略了一些东西:
Dim rng As Range
Set rng = ThisWorkbook.Sheets("Sheets1").Range("C3").End(xlDown).Select
For Each c In rng
c.Value = c.Value / 60
Next
因此,基本思想是可以捕获C的最后一个值并将其除以60。
欢迎任何建议/想法。
非常感谢。
答案 0 :(得分:0)
Dim rng As Range, c As Range
With ThisWorkbook.Sheets("Sheets1")
'edit: switch to xlUp
Set rng = .Range(.Range("C3"), .Cells(.Rows.Count, "C").End(xlUp))
end with
For Each c In rng.Cells
'edit: check cell has a value...
If Len(c.value) > 0 Then c.Value = c.Value / 60
Next