Why does my vba filter select the entire sheet if only row 2 has data in it?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
So totally confused please help if you can,

I have this bit of code i offten use to filter copy paste,

not had a problem before but for some reason when only row 2 has data in it it selects the entire sheet?
anyone know why?

i've show the code below

please any help would be great

VBA Code:
Sub test4()


LrTarg = ODraw.Cells(Rows.Count, "M").End(xlUp).Row
If LrTarg > 1 Then
ODraw.Range("M2:M" & LrTarg).SpecialCells(xlCellTypeVisible).Select



End If
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
If SpecialCells is anchored to a single cell it will look at the entire sheet.
Try
VBA Code:
If LrTarg > 2 Then
 
Upvote 0
Oh, wow, thats news !
ok so i will try that work around
Thannsk
Tony
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,870
Messages
6,122,019
Members
449,060
Latest member
LinusJE

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