发布网友 发布时间:2022-05-30 00:57
共1个回答
热心网友 时间:2023-09-11 08:07
EXCEL标准功能是无法做到不让复制的。做一个事件驱动程序可以实现。例如有一张工作表,*对第3列复制。当鼠标对第3列进行选择区域时,自动回到单元格A1。代码如下:Private Sub Worksheet_SelectionChange(ByVal Target As Range)Dim mYadd As StringDim mYadds, mYadde, mYs As StringDim addaDim I, J As IntegermYadd = Target.AddressI = Len(mYadd) - Len(Replace(mYadd, ":", ""))If I = 0 And ActiveCell.Column <> 3 Then Exit SubEnd IfIf I = 0 And ActiveCell.Column = 3 Then GoTo 100End Ifadda = Split(mYadd, ":")mYadds = adda(0)mYadde = adda(1)For I = 0 To 9mYs = Trim(Str(I))mYadds = Replace(mYadds, mYs, "")mYadde = Replace(mYadde, mYs, "")Next ImYadds = Replace(mYadds, "$", "")mYadde = Replace(mYadde, "$", "")If Asc(mYadds) <= Asc("C") And Asc(mYadde) >= Asc("C") Then GoTo 100Else Exit SubEnd IfExit Sub 100 MsgBox "第3列不可复制" Cells(1, 1).SelectEnd Sub(边工作边写代码,这个程序调是调通了,有兴趣的可以修改一下。看着可能有点乱)如果选择包含第三列,会报警。如图: