EXCEL VBA 求写判断当前SHEET的代码
发布网友
发布时间:2023-10-27 03:20
我来回答
共2个回答
热心网友
时间:2024-12-12 09:08
BOOK2的thisworkbook代码:
Private Sub Workbook_Open()
if avcivesheet.name="Sheet7" then
set wb=workbooks.open(thisworkbook.path & "\book1.xls",,false)
with wb
.worksheets("Sheet1").setlect
run "book1.xls!a"
end with
end if
End Sub追问你好,请看补充问题,没有料到会用上Private Sub,这个不怎么会用,只会用SUB,调用的时候也方便。请修改
追答sub test()
if avcivesheet.name="Sheet7" then
set wb=workbooks.open(thisworkbook.path & "\book1.xls",,false)
with wb
.worksheets("Sheet1").setlect
a
end with
end if
end sub
热心网友
时间:2024-12-12 09:08
Private Sub Workbook_Open()
If ActiveSheet.Name = "Sheet7" Then
Workbooks.Open ThisWorkbook.Path & "\Book1.xls"
Workbooks("Book1.xls").Worksheets("Sheet1").Activate
End If
End Sub
追问你好,请看补充问题,没有料到会用上Private Sub,这个不怎么会用,只会用SUB,调用的时候也方便。请修改