我用vb控制excel表格,再运行时老是报Range类不能使用Locked属性,有段代码请各位看看。指点指点。
SubFlowmisExcelVbastart()''FlowmisExcelVbastartMacro'user记录的宏2002-9-27'ActiveSheet.Un...
Sub FlowmisExcelVbastart()
'
' FlowmisExcelVbastart Macro
' user 记录的宏 2002-9-27
'
ActiveSheet.Unprotect
ActiveSheet.Range("C15,G16,I16,H19,H21,H23,H25,H27,C18,G18,I18,C20,G20,I20,C22,G22,I22,C24,G24,I24,C26,G26,I26,C29,G30,I30,D5,D6,D7,H7,F8,F9,F10,C12,G13,I13").Select
Selection.Locked = True
Selection.FormulaHidden = False
Selection.Font.ColorIndex = 0
ActiveSheet.Protect DrawingObjects:=True, contents:=True, Scenarios:=True
If (ActiveSheet.Range("N10").Value = "综合部") Then
Application.ActiveSheet.Range("D5,D6,D7,H7,F8,F9,F10,C12,G13,I13,C15,G16,I16,H19,H21,H23,H25,H27").Select
Selection.Locked = False
Selection.FormulaHidden = False
Selection.Font.ColorIndex = 0
ActiveSheet.Protect DrawingObjects:=True, contents:=True, Scenarios:=True
End If
End Sub 展开
'
' FlowmisExcelVbastart Macro
' user 记录的宏 2002-9-27
'
ActiveSheet.Unprotect
ActiveSheet.Range("C15,G16,I16,H19,H21,H23,H25,H27,C18,G18,I18,C20,G20,I20,C22,G22,I22,C24,G24,I24,C26,G26,I26,C29,G30,I30,D5,D6,D7,H7,F8,F9,F10,C12,G13,I13").Select
Selection.Locked = True
Selection.FormulaHidden = False
Selection.Font.ColorIndex = 0
ActiveSheet.Protect DrawingObjects:=True, contents:=True, Scenarios:=True
If (ActiveSheet.Range("N10").Value = "综合部") Then
Application.ActiveSheet.Range("D5,D6,D7,H7,F8,F9,F10,C12,G13,I13,C15,G16,I16,H19,H21,H23,H25,H27").Select
Selection.Locked = False
Selection.FormulaHidden = False
Selection.Font.ColorIndex = 0
ActiveSheet.Protect DrawingObjects:=True, contents:=True, Scenarios:=True
End If
End Sub 展开
2013-01-17
展开全部
你工作表中有合并的单元格,要取消合并
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
locked干什么?去掉这句不就完了吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
locked属性之前,要ActiveSheet.Unprotect才能执行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询