I have no clue what is causing this issue. I have a simple macro that creates new tabs and names them, then filters data from one tab and pastes it to their corresponding tab.
Here is my code:
Sub Tabs()
Dim wbRecovery As Workbook
Dim wsFac As Worksheet
Set wbRecovery = ThisWorkbook
Set wsFac = wbRecovery.Sheets("Facility Rec Bucket & Year")
With wbRecovery
Sheets.Add After:=Sheets(Sheets.Count), Count:=17
Sheets(5).Name = "DANES"
Sheets(6).Name = "DCEND"
Sheets(7).Name = "DCHED"
Sheets(8).Name = "DCNUR"
Sheets(9).Name = "DCRIC"
Sheets(10).Name = "DEMER"
Sheets(11).Name = "DHEMA"
Sheets(12).Name = "DMED"
Sheets(13).Name = "DNEUR"
Sheets(14).Name = "DNSUR"
Sheets(15).Name = "DOBGY"
Sheets(16).Name = "DOPHT"
Sheets(17).Name = "DPEDS"
Sheets(18).Name = "DPMR"
Sheets(19).Name = "DPSYC"
Sheets(20).Name = "DRADS"
Sheets(21).Name = "DSURG"
End With
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DANES"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DANES").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DCEND"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DCEND").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DCHED"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DCHED").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DCNUR"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DCNUR").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DCRIC"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DCRIC").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DEMER"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DEMER").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DHEMA"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DHEMA").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DMED"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DMED").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DNEUR"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DNEUR").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DNSUR"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DNSUR").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DOBGY"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DOBGY").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DOPHT"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DOPHT").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DPEDS"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DPEDS").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DPMR"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DPMR").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DPSYC"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DPSYC").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DRADS"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DRADS").Range("A1")
wsFac.Range("A1").AutoFilter Field:=1, Criteria1:=("DSURG"), _
Operator:=xlFilterValues
wsFac.Cells.Copy Destination:=wbRecovery.Sheets("DSURG").Range("A1")
End Sub
When I run this code as is, after the OBGY tab is pasted I get the error "Excel Cannot complete task with available resources ". The tab where the data is being copied from is not abnormally large, it's only 566 rows and 14 columns wide (I wouldn't consider that large at all for Excel). If I run the lines of code individually or in chunks of 5-8 it works perfect. All the data is copied and pasted correctly but when I run it as a whole I get the same issue.
Is there something wrong with my computer or Excel itself?
I deleted a lot of stuff off my desktop so I didn't think it was a storage issue. Also when I do the process manually I have no issues. I have also tried Application.CutCopyMode = False
and that hasn't worked either