VBA for Excel
来源:百度知道 编辑:UC知道 时间:2024/06/28 10:07:51
Private Sub CommandButton1_Click()
Dim i As Integer
Dim k As String
这段代码老提示If Cells(i, 0) <> Cells(i + 1, 0) Then这句有错,麻烦大家帮忙看一下
For i = 0 To 45
If Cells(i, 0) <> Cells(i + 1, 0) Then
Cells(i, 0) = Cells(i, 1)
k = Cells(i, 0)
End If
Next i
End Sub
Dim i As Integer
Dim k As String
这段代码老提示If Cells(i, 0) <> Cells(i + 1, 0) Then这句有错,麻烦大家帮忙看一下
For i = 0 To 45
If Cells(i, 0) <> Cells(i + 1, 0) Then
Cells(i, 0) = Cells(i, 1)
k = Cells(i, 0)
End If
Next i
End Sub
Cells(i,0)???
Cells(x,y)的意思是第x行,第y列交叉所在的单元格。
那么有0肯定是出错了,另外
For i = 0 To 45这里也至少应该改为:
For i = 1 To 45
Cells是从1开始计算的,而非0.