Categories

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

Auto Draft

最近有同事要求他设定的excel单元格,不能被粘贴。因为这个单元格被设置了格式,限定一定的字符数,手工录入,是可以达到目的,但是如果这个单元格被粘贴了,那么限定字符的功能就失效,解决办法是,只能让手动录入,而不能粘贴。

在网上查了下,发现有个方法不错,这里介绍下,这个方法要在源文件里写代码,打开源文件有两个方法:

1. 工具 – 宏 – Visual Basic 编辑器

2. 在当前工作表的最下面名字上点右键,选择“查看代码”

打开代码编辑器后,会出现一个Visual Basic 编辑区域,如下图:

看好左边的sheet1, sheet2, sheet3, 这个是你要设定的工作表,别点错了。然后将下面的代码直接粘贴进去就好了,其中的”A1:A15, A20″是你要禁止粘贴的单元格:(下面的代码粘贴后,如果出现红色,说明代码错误,一般是双引号问题,将全角的双引号,修改为半角的即可。)

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range(“A1:A15, A20″)) Is Nothing Then
Application.CellDragAndDrop = False
Else
Application.CellDragAndDrop = True
End If
End Sub
Private Sub Worksheet_Deactivate()
Application.CellDragAndDrop = True
End Sub

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>