With some of my workbooks I get a #REF!
error after updating my workbook.
I have to filter data to a worksheet Januari to filter Januari, and get a total sum in Sheet Total.
The code I have is working perfectly, but when I want to copy the total from column "C" to another worksheet I get a #REF!
error.
Here is the line I get in my original sheet: =SOM('WABO Oktober'!#VERW!)
, where is should be: =SOM('WABO Oktober'!E:E)
It does not happen in all the workbooks, just the one I need the most.
Here is a example of my code.
Sub Test()
Dim My_Range As Range
Dim Maand As String
Maand = ActiveSheet.Name
' This is the name of the First part of the filtersheet
Naam = ("filter")
' Make sure sheet is visible
Sheets((Naam) & " " & Maand).Visible = True
Sheets(Maand).Select
' Range on active sheet
Set My_Range = Range("A2:Y999")
My_Range.Parent.Select
'Remove AutoFilter
My_Range.Parent.AutoFilterMode = False
' Select the columns you want to filter
My_Range.AutoFilter Field:=2, Criteria1:="y"
'Copy/paste the visible data to the new worksheet
Sheets((Naam) & " " & Maand).Select
My_Range.Parent.AutoFilter.Range.Copy
With ActiveSheet.Range("A1")
.PasteSpecial Paste:=8
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
Application.CutCopyMode = False
.Select
End With
'AutoFit All Columns on Worksheet
ActiveSheet.Cells.EntireColumn.AutoFit
'Close AutoFilter
My_Range.Parent.AutoFilterMode = False
' Remove colums to create data filter Januari
Range("A:A").Select
Range("C1").Activate
Selection.Delete Shift:=xlToLeft
' Got to cell A1
ActiveSheet.Range("A1").Select
'Go back to the "Maand" Sheet
Worksheets(Maand).Activate
ActiveSheet.Range("A1").Select
'Hide the filter Januari sheet
Sheets((Naam) & " " & Maand).Visible = False
'Refresh workbook
ActiveWorkbook.RefreshAll
End Sub