VBA Charts removed after deleting filtered rows

NewDataGuy

New Member
Joined
Apr 30, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi all,
this is my first post on here but I have spent previously several hours (if not days) on here finding the solutions to my problems. But for the current miracle, I do not find a similar use case which can help me.

Here my problem:

I have a tab containing several tables and charts in between. Based on this tab, several different versions which only contain a part of it are rolled-out and saved in different files.
In order to do this, I am filtering on a column (which contains a Identifier whether the is needed for the current version) and then deleting all visible rows.
This worked perfectly in the past. But suddenly (without any know changes from my side) the code is not working as expected. Now I am also deleting the charts which are filtered out (Properties are set to "Move and size with cells") and should remain in the final versions.
Does somebody has an idea what is going wrong?

This is the relevant part of the code

With Sheets(strTarget)
.ShowAllData
.AutoFilterMode = False
'Set filter
.Range(Cells(ROW_FILTER_ROW, COL_FILTER_COLUMN), Cells(intLastRowUsed, COL_FILTER_COLUMN)).AutoFilter Field:=1, Criteria1:="<>" & "X"
'Delete rows
intFirstRowFilter = .AutoFilter.Range.Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row
intLastRowFilter = .Range("A" & Rows.Count).End(xlUp).Row
If intFirstRowFilter < 10000 And intLastRowFilter < 10000 And intFirstRowFilter < intLastRowFilter And _
intFirstRowFilter <> 0 And intLastRowFilter <> 0 And ROW_FILTER_ROW <> intFirstRowFilter And ROW_FILTER_ROW <> intLastRowFilter Then
.Rows(intFirstRowFilter & ":" & intLastRowFilter).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End If
'Delete filter
.ShowAllData
.AutoFilterMode = False
End With


Thanks for any help or hint!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
If you delete rows that contain a chart, and the chart is set to move and resize with cells, the chart will also be deleted. If the chart is set not to move and resize, it will not be deleted.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

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