Remove Selection

Haree

Board Regular
Joined
Sep 22, 2019
Messages
146
Office Version
  1. 2016
Hi, I have a code which does the work which i want perfectly. But after the code runs it selects a certain range. Can someone please guide me so that nothing is selected. Sorry if its very elementary.

VBA Code:
Sub transfer()
'Transfer modified and aligned data to Daily Sheet
Application.ScreenUpdating = False
Dim ws As Worksheet
Dim Range1 As Range
Dim lr As Long

Set ws = ThisWorkbook.Worksheets("Daily Extract")
lr = Range("A" & Rows.Count).End(xlUp).Row
Set Range1 = ws.Range("A1:K" & lr)
    With ws
        With Range1
                .AutoFilter 3, "="
                    lr = Range("A" & Rows.Count).End(xlUp).Row
                    If lr > 1 Then
                    Range("A2:A" & lr).Select
                    Selection.Delete Shift:=xlUp
                    End If
                .AutoFilter
        End With
    End With
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

Regards
Haree
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi
Replace
VBA Code:
 Range("A2:A" & lr).Select
                    Selection.Delete Shift:=xlUp
With

VBA Code:
 Range("A2:A" & lr).Delete Shift:=xlUp
 
Upvote 0
Solution
You're very welcome
And thank you for the feedback
Be happy and safe
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

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