# VBA - how to get rid of the "gray area selected" where I have pasted some data? [image attached]



## cmcamilo (Dec 21, 2022)

Hello,

I have a code to copy and paste some data from one sheet to another. But when I do the area pasted is gray. Although this isn't very important, in aesthetic terms I would prefer that area not to be selected afterwards.
This should be really basic, but I am not very good at VBA and need some help... Can you help me?
Thank you.


----------



## davesexcel (Dec 21, 2022)

You never supplied a code. I assume you selected the range before you pasted.


----------



## cmcamilo (Dec 21, 2022)

davesexcel said:


> You never supplied a code. I assume you selected the range before you pasted.


Oh sorry! Yes! This is the code:

```
Sub Kommbox_Mecânica_button()

ActiveSheet.Range("A11:AB39").ClearContents

If ActiveSheet.ChartObjects.Count > 0 Then
    ActiveSheet.ChartObjects.Delete
End If

Dim shp As Shape
For Each shp In ActiveSheet.Shapes
    If shp.Type = msoSlicer Then shp.Delete
Next shp

Workbooks("Kommbox_teste - Copy.xlsm").Worksheets("Gráfico_Kommbox_Mecânica").Range("A1:AB39").Copy
Sheets("Dashboard").Activate
Range("A11").Select

ActiveSheet.Paste

Application.CutCopyMode = False


End Sub
```


----------



## davesexcel (Dec 22, 2022)

Still looks like something is selected possibly Range("A11:AB39") is selected before you run the code?

You can copy and paste without using select as well.


```
Workbooks("Kommbox_teste - Copy.xlsm").Worksheets("Gráfico_Kommbox_Mecânica").Range("A1:AB39").Copy _
Sheets("Dashboard").Range("A11")
```


----------



## cmcamilo (Dec 22, 2022)

davesexcel said:


> Still looks like something is selected possibly Range("A11:AB39") is selected before you run the code?
> 
> You can copy and paste without using select as well.
> 
> ...


It worked in a sense that it doesnt select the area anymore, but I get this message:



My sheet doesnt work as I want it to work anymore because the formulas are lost.


----------



## davesexcel (Dec 22, 2022)

Are you saying the range copied is formulas? from a different workbook?

I'm not sure, you need to supply additional information


----------



## Gokhan Aycan (Dec 22, 2022)

You could re-select A11 (or any other cell) after pasting with your original code.


----------



## cmcamilo (Dec 23, 2022)

Gokhan Aycan said:


> You could re-select A11 (or any other cell) after pasting with your original code.


Thanks, that will do!


----------

