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")
 

Some videos you may like

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
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?
 

mill1174

New Member
Joined
Feb 26, 2016
Messages
2
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
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
This is the line that's doing it.
Range("A:K").Select

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

Watch MrExcel Video

Forum statistics

Threads
1,122,915
Messages
5,598,850
Members
414,263
Latest member
sherrcha

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
Top