VBA Help

JoeyGaspard

Board Regular
Joined
Jul 22, 2019
Messages
147
Hi folks, having another little problem with VBA. I am trying to filter a selection from a worksheet, and delete those rows, my filter is working fine, but its not deleting the rows. Here is the code and a screenshot:
'Clean up GrowthRate
With Sheets("GrowthRate")
.AutoFilterMode = False
With .Range("k2", .Range("k" & Rows.Count).End(xlUp))
.AutoFilter 11, "0"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With

1604679857712.png

Thanks in advance!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Not sure if this will work but try replacing this
.Offset(1).SpecialCells(12).EntireRow.Delete

with this
VBA Code:
.Offset(1).SpecialCells(12).Columns.EntireRow.Delete
 
Upvote 0
Hi folks, having another little problem with VBA. I am trying to filter a selection from a worksheet, and delete those rows, my filter is working fine, but its not deleting the rows. Here is the code and a screenshot:
'Clean up GrowthRate
With Sheets("GrowthRate")
.AutoFilterMode = False
With .Range("k2", .Range("k" & Rows.Count).End(xlUp))
.AutoFilter 11, "0"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With

View attachment 25620
Thanks in advance!
Sorry guys, I need to make an update, I was able to get the rows to delete, but I dont need the entire row deleted, just columns A:J, so in short, I want to filter off of row k, delete only rows A thru J of the filtered results.
 
Upvote 0
Not sure if this will work but try replacing this
.Offset(1).SpecialCells(12).EntireRow.Delete

with this
VBA Code:
.Offset(1).SpecialCells(12).Columns.EntireRow.Delete
Thank you for the help, it helped me to see what I needed which I reposted on my original post. Thanks again!
 
Upvote 0
I am having a problem with this code, I believe it is because I am trying to autofilter a table, it will filter the table and remove the data, it just wont return to the remaining data, its as if it just stays on the filtered data, as if the autofilter is not "turning off". I have read that there is a difference in autofiltering a table, but I am unable to figure it out, any help is appreciated, the code is below:

'Clean up GrowthRate
With Sheets("GrowthRate")
.AutoFilterMode = False
With .Range("k2", .Range("k" & Rows.Count).End(xlUp))
.AutoFilter 11, "0"
On Error Resume Next
Range("a2:j2", Range("a2:j2").End(xlDown)).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
.AutoFilterMode = False
End With
 
Upvote 0
Have a look here
 
Upvote 0
Have a look here
Thank you Fluff, but my problem still remains, the rows are being removed, but my issue is still that the sheet "GrowthRate", remains in a filtered state as if the autofilter is not turning off, even though those rows are gone, the sheet stays as if its filtered, see below:

1605115086728.png
 
Upvote 0
Have you modified your code to work in a table?
 
Upvote 0
Have you modified your code to work in a table?
That is what I was saying, I read up on it, but couldnt quite understand it or get it to work. I tried that before I posted here. So short answer, no, I am using the same code you helped me with last time, which fixed the problem i was having deleting the filtered rows, but now it is doing what my original statement says.
 
Upvote 0
The code you supplied in post#5 is not using a table, so if that is not the code you are trying to use, please post the code that you are using.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,707
Members
448,981
Latest member
recon11bucks

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