0

After my code performs a copy & special paste of a whole external worksheet into the current workbook, the target remains selected. It seems than in the past there was a .Deselect() function?

I have attempted to select the cell [1,1], but the app crashes with a COM error.

For reference, this is one of many sites that provide methods that fail to work:

 https://www.pcreview.co.uk/threads/programmatically-deselect-a-selection.2412034/

TIA

  • It's literally impossible for us to answer the issue if you don't give us the specific error and the specific code. – Samuel Hulla May 23 '18 at 10:54
  • You don't need to select a range to copy it. See [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). Do you mean that you want to set `Application.CutCopyMode = False` ? Also, [it's almost impossible to advise further without details of your code, and the error.](http://idownvotedbecau.se/nocode/) – Olly May 23 '18 at 11:19
  • Olly: The Application.CutPasteMode = false statement only works for BASIC. In C# it is an enumeration of modes, none of them are "off" or "false". – Travis Banger May 23 '18 at 12:39
  • Rawrplus: You are 100% correct. I was looking for the COM specific COM error code, but my Internet went down last night. Will add it from the office later. – Travis Banger May 23 '18 at 12:41

1 Answers1

2

You need to select another range/cell if you want to deselect another region.

ActiveSheet.Range("a1").Select();
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45