请教大神,运行下面这段excel 代码,出现错误代码:1004.类range的sort方法无效,请问为什么?该怎样修改
PublicSub第一个过程()DimiAsIntegerDimjAsIntegericestorage=Sheet4.Cells(11,14).ValueDimload...
Public Sub 第一个过程()
Dim i As Integer
Dim j As Integer
icestorage = Sheet4.Cells(11, 14).Value
Dim load(4344 To 4391) As Variant
Dim elecprice(4344 To 43911) As Variant
For i = 181 To 182
sumload = 0
For j = 7 To 23
k = 24 * i + j
load(k) = Sheet1.Cells(4 + 24 * i + j, 3).Value
elecprice(k) = Sheet1.Cells(4 + 24 * i + j, 6).Value
sumload = sumload + load(k)
Next j
If sumload > icestorage Then
i1 = i * 24 + 11
i2 = i * 24 + 26
i3 = i * 24 + 10
Range("B" & CStr(i1), "F" & CStr(i2)).Select
Selection.Sort Key1:=Range("F" & CStr(i3)), Order1:=xlDecending
Else
End If
Next i
End Sub 展开
Dim i As Integer
Dim j As Integer
icestorage = Sheet4.Cells(11, 14).Value
Dim load(4344 To 4391) As Variant
Dim elecprice(4344 To 43911) As Variant
For i = 181 To 182
sumload = 0
For j = 7 To 23
k = 24 * i + j
load(k) = Sheet1.Cells(4 + 24 * i + j, 3).Value
elecprice(k) = Sheet1.Cells(4 + 24 * i + j, 6).Value
sumload = sumload + load(k)
Next j
If sumload > icestorage Then
i1 = i * 24 + 11
i2 = i * 24 + 26
i3 = i * 24 + 10
Range("B" & CStr(i1), "F" & CStr(i2)).Select
Selection.Sort Key1:=Range("F" & CStr(i3)), Order1:=xlDecending
Else
End If
Next i
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询