NewDataGuy
New Member
- Joined
- Apr 30, 2022
- Messages
- 1
- Office Version
- 365
- Platform
- 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!
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!