|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
数据需要修正,代码如下
- Option Explicit
- Sub Test()
- Dim SH As Worksheet, arr As Variant, lngRow As Long
- Dim dateStart As Date, dateResult As Date
- Dim dblHour As Double, dblMin As Double
- Dim lngBasicEff As Long
-
- Set SH = Sheets("Sheet1")
- lngBasicEff = SH.Range("H1").Value '基础效率
-
- arr = SH.Range("A1").CurrentRegion
-
- For lngRow = 2 To UBound(arr) - 1
- dateStart = arr(lngRow, 3) '开始时间
- dblHour = arr(lngRow, 2) / lngBasicEff '耗时=数量/基础效率
- dblMin = arr(lngRow, 5) '时间调整
-
- arr(lngRow, 4) = dblHour
- dateResult = DateAdd("h", dblHour, dateStart)
- dateResult = DateAdd("n", dblMin, dateResult)
- arr(lngRow + 1, 3) = Format(dateResult, "yyyy/mm/dd hh:mm")
- Next
- SH.Range("A1").CurrentRegion = arr
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|