我写了一个excel工作表,当我按下一个按钮时,循环会在一些行中运行,如果它们是空的,就会编辑一些数据,但是我似乎无法让宏运行,因为它一直在返回450错误。以下是不会运行的代码的简化版本。(从选项开始,在结束子格式时显式结束,当我粘贴进来时会出错)
Option Explicit
Sub Copypaste()
'
' Copypaste Macro
'
' Keyboard Shortcut: Ctrl+p
'
Dim i As Integer, j As Integer
Dim ls As Boolean
i = 2
j = 24
ls = True
Do While ls = True
If IsEmpty(i, j) = True Then
Cells(i, j).Value = 10
ls = False
Else
ls = True
End If
i = i + 1
j = j + 1
If i > 10 Then
ls = False
End If
Loop
End Sub
我已经搜索了大量的线程,我似乎找不到和我的问题相同的人,我所做的任何修正似乎都不是问题所在。
宏是新的,就像今天发现的那样,因此可能会出现多个错误。
发布于 2016-02-29 17:33:37
你需要改变
If IsEmpty(i, j) = True Then
至
If IsEmpty(Cells(i, j).Value2) = True Then
https://stackoverflow.com/questions/35705660
复制相似问题