Hi,
I run this script with a button within a worksheet:
With the button, the code works as I want it to. Now I´m trying to put the code in the same worksheets Activate procedure, but then I get the error message: "Run time error 1004: We can´t do that to a merged cell", and the following part of the code is marked:
In the sheet where the advanced filter is done, there are no merged cells.
Any suggestions on what I´m doing wrong?
I run this script with a button within a worksheet:
Code:
Sub updatepersonnellist()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Sheets("Resurstid").Visible = True
Sheets("Resurstid").Select
Columns("A:F").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _
"H1:M2"), CopyToRange:=Range("H4"), Unique:=True
Sheets("Analys per konsult").Select
With Sheets("Analys per konsult")
With .Range("B15:N1000")
.Clear
End With
Dim lastRow2 As Long
lastRow2 = Sheets("Resurstid").Range("H" & Rows.Count).End(xlUp).Row + 7
Sheets("Analys per konsult").Range("B12:N12").Copy Sheets("Analys per konsult").Range("B13:N" & lastRow2)
End With
Sheets("Resurstid").Visible = False
Application.Calculation = xlCalculationAutomatic
End Sub
With the button, the code works as I want it to. Now I´m trying to put the code in the same worksheets Activate procedure, but then I get the error message: "Run time error 1004: We can´t do that to a merged cell", and the following part of the code is marked:
Code:
Columns("A:F").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _
"H1:M2"), CopyToRange:=Range("H4"), Unique:=True
In the sheet where the advanced filter is done, there are no merged cells.
Any suggestions on what I´m doing wrong?