高分求谁能帮我编个VB程序

来源:百度知道 编辑:UC知道 时间:2024/06/30 13:33:45

原装正品V6版中的一小部分.

Sub Calc()

Dim dn As Double
Dim dn1 As Double
Dim i As Integer
Dim j As Integer

Application.EnableEvents = False

Range("A:A").ClearComments
Range("C2:E20000").ClearContents
Range("A:A").NumberFormatLocal = "yyyy-mm-dd hh:mm;@"

If Hour(Right(Cells(3, 1).Text, 5)) <> 0 Or Minute(Right(Cells(3, 1).Text, 5)) <> 0 Then
Rows(3).EntireRow.Insert
Cells(3, 1) = DateValue(Left(Cells(4, 1).Text, 10)) & " " & TimeValue("00:00:00")
dn = 24 - (Hour(TimeValue(Right(Cells(2, 1).Text, 5)) - TimeValue(Right(Cells(4, 1).Text, 5))) + Minute(TimeValue(Right(Cells(2, 1).Text, 5)) - TimeValue(Right(Cells(4, 1).Text, 5))) / 60)
dn1 = Hour(TimeValue(Right(Cells(4, 1).Text, 5))) + Minute(TimeValue(Right(Cells(4, 1).Text, 5))) / 60
Cells(3, 2) = Cells(4, 2) - dn1 * (Cells(4, 2) - Cells(2, 2)) / dn