|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
运行错误,424,要求对象
不知道哪里出问题了,代码是下载的,按说不会错啊
程序码
Sub test8()
Dim sh As Worksheet
Set sh = activeworbook.Sheets(1)
'Do
For Each sh In ActiveWorkbook
If sh.Name = "Sheet1" Then
sh.Range("A1").Value = "HaHa"
Exit For
End If
Next
'Loop
Sheets("sheet1").Select
ActiveSheet.Range("A1").Value = "Hello"
'在当前活动sheet前添加一个新sheet
ActiveWorkbook.Worksheets.Add ActiveSheet
'新sheet会成为活动sheet,给它一个名字
ActiveSheet.Name = "New sheet1"
ActiveWorkbook.Worksheets.Add ActiveSheet
ActiveSheet.Name = "New sheet2"
'因为删除sheet会弹出警告消息,所以先禁止警告消息
Application.DisplayAlerts = False
ActiveWorkbook.Worksheets(2).Delete
'恢复警告消息
Application.DisplayAlerts = True
End Sub
|
|