Remove Dashed Lines from Copy Paste VBA in Excel

Add to Favorites
Author:

How to remove the flashing dashes from a copy/paste range using VBA in Excel; this removes the dashed outline that appears once a paste has been completed using a macro.

265d964b67cca018bd1143f4f3b5b61d.png

Sections:

The Code

Useful Example

Notes

The Code

Application.CutCopyMode = False

Put this piece of code anywhere after you finish copying and pasting a range.

Useful Example

Sub copy_data()

'copy the data
Range("A1:A5").Copy

'paste the data
Range("C1:C5").PasteSpecial

'remove the dashed line
Application.CutCopyMode = False

'select a single cell (deselects the copied range)
Range("A1").Select

End Sub

a52962741fdc40d5ea2b68b0a7ae5847.jpg

This code simply copies data from range A1:A5 to C1:C5.

Notice that the code to remove the dashed lines appears after the copy/paste is finished.

Deselect the Copied Range

One extra thing I did at the bottom of the code is to deselect the range of cells that was copied.

To do this, I simply selected another cell, A1, using this code: Range("A1").Select

Notes

You can test the above code to see what it looks like without the additional lines that remove the dashes and deselect the copied range, just place a single quote in front of those lines to see the result without them.

Download the attached file to get this example in Excel.


Downloadable Files: Excel File

Question? Ask it in our Excel Forum


Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons 50+ Hours of Instruction 200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Similar Content on TeachExcel
Copy and Paste Data using Macro VBA in Excel
Tutorial: How to copy and paste data using a Macro in Excel. I'll show you multiple ways to do this,...
Quickly Clear all Formatting in Excel
Tutorial: How to remove all formatting from cells at once in Excel. This includes removing any and...
Activate or Navigate to a Worksheet using Macros VBA in Excel
Tutorial: Make a particular worksheet visible using a macro in Excel. This is called activating a wo...
Get the Last Row using VBA in Excel
Tutorial: (file used in the video above) How to find the last row of data using a Macro/VBA in Exce...
Extract a Word from a Sentence / Cell in Excel with this UDF - Allows for a User-Defined Delimiter
Macro: Extract whole words from a cell or sentence in Excel with this UDF. This allows you to spe...
Filter Data to Show the Top 10 Items from a Data Set in Excel - AutoFilter
Macro: This Excel macro filters data in Excel in order to display the top 10 items from the data ...
Tutorial Details
Downloadable Files: Excel File
Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course