Hi all
I'm using a piece of code I've found that has worked for me in the past but now I'm receiving Run time Error 1004 : cannot use that command on overlapping sections.
I looked up possible fixes and aware it's something to do with non contiguous or hidden columns/rows and perhaps Intersect was a solution but I can't get it to work.
I have ensure that all columns and rows are unhidden.
I've sorted my data range and lkup range in order and ensured I only have unique values in lkup range. Struggling now for a solution?
Here's my code and the offset line is the error. Any help appreciated! thank you in advance!
I'm using a piece of code I've found that has worked for me in the past but now I'm receiving Run time Error 1004 : cannot use that command on overlapping sections.
I looked up possible fixes and aware it's something to do with non contiguous or hidden columns/rows and perhaps Intersect was a solution but I can't get it to work.
I have ensure that all columns and rows are unhidden.
I've sorted my data range and lkup range in order and ensured I only have unique values in lkup range. Struggling now for a solution?
Here's my code and the offset line is the error. Any help appreciated! thank you in advance!
VBA Code:
Sub SplitandFilterSheet()
'Step 1 - Name your ranges and Copy sheet
'Step 2 - Filter by Department and delete rows not applicable
'Step 3 - Loop until the end of the list
Dim Splitcode As Range
Sheets("Master").Select
Set Splitcode = Range("Splitcode")
For Each cell In Splitcode
Sheets("Master").Copy After:=Worksheets(Sheets.Count)
ActiveSheet.Name = cell.Value
With ActiveWorkbook.Sheets(cell.Value).Range("MasterData")
.AutoFilter Field:=6, Criteria1:="<>" & cell.Value, Operator:=xlFilterValues
'.Intersect.SpecialCells(xlCellTypeVisible).EntireRow.Delete
'.Intersect(ActiveSheet.Cells, .Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow).Delete
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
ActiveSheet.AutoFilter.ShowAllData
Next cell
End Sub