共享工作簿中的宏错误 [英] macros error in a shared workbook

查看:93
本文介绍了共享工作簿中的宏错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述








我在excel 2012中有一个共享和受保护的电子表格。(受保护但没有密码)我写了这个宏:

I have a shared and protected worsheet in excel 2012. (protected but without password) I wrote this macro:

Private Sub CommandButton1_Click()
    ActiveSheet.Unprotect
    Range("B4:K38").Select
    Selection.Sort Key1:=Range("D4"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
   'cells I don't want to be protect (to be user-editable)
    Range("B4:K38").Locked = False
   'protecting the sheet, and all the other cells will be protected
    Protect UserInterfaceOnly:=True
End Sub

但每次我使用这个宏时,都会有一条消息告诉我方法保护有错误。

But everytime I use this macro I have a message that shows me that there's an error with the method protect.

我做错了什么?

推荐答案

尝试更改 保护UserInterfaceOnly := True to

ActiveSheet .Protect UserInterfaceOnly := True



ActiveSheet.Protect UserInterfaceOnly:=True


这篇关于共享工作簿中的宏错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆