粘贴数据后取消选择列 [英] Unselect column after pasting data
问题描述
这可能很简单,但是我无法解决这个问题。
this may be very simple but I am not able to work around it.
我可以通过使用 Application.CutCopyMode = False
但数据粘贴的列仍然保持选中状态,我尝试 ActiveSheet.EnableSelection = xlNone
其中一个论坛没有任何成功我的代码工作正常:
I could free up the column from where I am copying data by using Application.CutCopyMode=False
but the column where data is pasted is still remain selected, I tried ActiveSheet.EnableSelection = xlNone
as suggested in one of the forum without any success rest of my code working fine:
Dim wb As Workbook
Dim t1 As Worksheet
Dim r As Worksheet
Set wb = ActiveWorkbook
Set t1 = Sheets("dataT1")
Set r = Sheets("HPV1report")
t1.Range("D3:CR5").Copy
r.Range("A2").PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=True
Selection.EntireColumn.AutoFit
End sub
我可以想到的其他事情是选择单元格A1,以便该列可以免费使用,但是如果可以的话我宁愿使用选择。
Other thing I can think of is selecting Cell A1 so the column will get free but I will prefer to use select if i can.
推荐答案
你不能真正取消选择单元格,因为它是工作表的性质,总是有一个选定的单元格。
You can not really un-select a cell, because it is in the nature of a worksheet that there is always a selected cell.
可能没有选定单元格的唯一原因是
The only reason why there might be no selected cell is
- 您选择一个对象,如控件/按钮,等等。
- 或保护工作表免受@moosli指出的用户交互。
所以正确的方法是,你已经发现:
选择任何其他单元格,例如。 A1。
So the correct way to go is, as you already found out:
Select any other cell, eg. A1.
Worksheets("MySheet").Range("A1").Select
这篇关于粘贴数据后取消选择列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!