Deselect range after autofilter

mill1174

New Member
Joined
Feb 26, 2016
Messages
2
This seems incredibly simple and straight forward, but no matter how much testing and searching I do I am unable to resolve. I currently have scripting that turns on AutoFilter without selecting anything, but I thought I could copy the data and paste into a new worksheet without the data being selected. However, after it completes the action it does show columns A:K as selected. I have been unable to figure out how to deselect those columns on the worksheet nor have I been able to find out how to copy and paste without them being selected in the first place. Any guidance is appreciated. Thanks.

ws1.Range("A1:K1000").Copy Destination:=Sheets("copy").Range("A1:K1000")
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Welcome to the board.

The code as you posted it doesn't select anything.
It must be previous code that did the selecting.

Can you post the whole code?
 
Upvote 0
Full script below


Sub RunScript()


Application.ScreenUpdating = False
Application.DisplayAlerts = False

Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Sheets("Data")

Sheets.Add.Name = "copy"
Dim galreqws As Worksheet
Set galreqws = ThisWorkbook.Sheets("copy")

Sheets("Data").Select
Range("A:K").AutoFilter

ws1.Range("A1:K1000").Copy Destination:=Sheets("copy").Range("A1:K1000")

galreqws.Delete

'Sheets("Data").Select
Range("A:K").AutoFilter
Range("A:K").Select
Sheets("Buttons").Select


Application.ScreenUpdating = True
Application.DisplayAlerts = True


End Sub
 
Upvote 0
This is the line that's doing it.
Range("A:K").Select

It can just be removed, it's not needed at all.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,731
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top