excel vba 请高手帮忙看看我这代码哪里出错了?
PrivateSubWorksheet_SelectionChange(ByValTargetAsRange)a=Selection.Rowb=Selection.Col...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
a = Selection.Row
b = Selection.Column
If b >= 2 And b <= 7 And Cells(a, b) = "" And Cells(a, b - 1) <> "" Then
AppActivate "Mozilla Firefox"
End If
End Sub
我本来想达到的目的是,如果我点击的单元格位于是2-7列并且该单元格为空,并且该单元格左侧的单元格不为空,则切换只“IE浏览器”,但不知为什么只要我点中A列的任一单元格,excel总会报错:运行时错误‘1004’,应用程序定义或对象定义错误,按说我点a列单元格系统应该没有任何报错才对啊?
请高手帮忙看看到底该怎么改?谢谢!
应该是切换至“火狐浏览器” 展开
a = Selection.Row
b = Selection.Column
If b >= 2 And b <= 7 And Cells(a, b) = "" And Cells(a, b - 1) <> "" Then
AppActivate "Mozilla Firefox"
End If
End Sub
我本来想达到的目的是,如果我点击的单元格位于是2-7列并且该单元格为空,并且该单元格左侧的单元格不为空,则切换只“IE浏览器”,但不知为什么只要我点中A列的任一单元格,excel总会报错:运行时错误‘1004’,应用程序定义或对象定义错误,按说我点a列单元格系统应该没有任何报错才对啊?
请高手帮忙看看到底该怎么改?谢谢!
应该是切换至“火狐浏览器” 展开
展开全部
Cells(a, b - 1) 这个条件有可能让 列为0 出错
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
a = Selection.Row
b = Selection.Column
If b >= 2 And b <= 7 And Cells(a, b) = ""Then
if Cells(a, b - 1) <> "" then
AppActivate "Mozilla Firefox"
end if
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
a = Selection.Row
b = Selection.Column
If b >= 2 And b <= 7 And Cells(a, b) = ""Then
if Cells(a, b - 1) <> "" then
AppActivate "Mozilla Firefox"
end if
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询