在代码中:
Sub sync()
Dim Dindex As Long 'the index of the D value we are on currently.
Dim Aindex As Long 'the index of the A value we are on currently
Dim Gindex As Long 'the index of the A value we are on currently
Dim Dvalue As Double 'the cell in D value we want to normalize by -time
Dim Avalue As Double 'the A cell value - time
Dim Bvalue As Double
Dim Hvalue As Double
Dim Gvalue As Double 'the G cell value - time
Dindex = 3
Aindex = 3
Gindex = 3
Dvalue = Cells(Dindex, 4).Value 'start value
Avalue = Cells(Aindex, 1).Value 'start value
Gvalue = Cells(Gindex, 7).Value
Do While Dvalue <> 0
Do While Avalue < Dvalue
Aindex = Aindex + 1
Avalue = Range("A" & CStr(Aindex)).Value
Loop
Do While Gvalue < Dvalue
Gindex = Gindex + 1
Gvalue = Range("G" & CStr(Gindex)).Value
Loop
Bvalue = Cells(Aindex, 2)
If Avalue <> Dvalue Then
Aindex = Aindex - 1
Bvalue = (Bvalue + Range("A" & CStr(Aindex)).Value) / 2
End If
Hvalue = Cells(Gindex, 8).Value
If Gvalue <> Dvalue Then
Gindex = Gindex - 1
Hvalue = (Hvalue + Range("G" & CStr(Gindex)).Value) / 2
End If
Cells(Dindex, 10).Value = Dvalue
Cells(Dindex, 11).Value = Bvalue
Cells(Dindex, 12).Value = Hvalue
Dindex = Dindex + 1
Dvalue = Cells(Dindex, 4).Value
Loop
End Sub
该行出现错误:Avalue = Range(“ A”&CStr(Aindex))。Aindex值达到1048577时的值。我怀疑问题出在我试图达到如此大的水平单元格,代码的目标是将3个不同的时间系统值放在同一时间系统上,因此我需要超越该单元格。
答案 0 :(得分:0)
感谢BigBen,我发现excel列的最大值为1048576,并成功修复了我的代码。