Hi,
We have also similar problem with our makro. Can you help us? The wierd thing is that sometimes it is working (makro is schaduled to run in every half an hour).
Debug is highlighting Selection.QueryTable.Refresh BackgroundQuery:=False
Sub UpdateReport()
'Cancel screenuodating, set start-criterias and show all sheets
Application.ScreenUpdating = False
Sheets("Instructions").Select
AutoWeekChangeActive = Range("B6").Value
RunWeekChange = 0
Call ShowSheets
'Update sheet Produced QTY (PLPRODMGD)
Sheets("PLPRODMGD").Select
ActiveSheet.AutoFilterMode = off
Range("A4:H2000").Select
Selection.ClearContents
Selection.Borders.LineStyle = xlNone
Selection.Interior.ColorIndex = xlNone
Selection.Font.Bold = False
Range("A4").Select
Range("B3").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("B3").Select
If ActiveCell.Offset(1, 0) = "" Then
ActiveCell.Offset(2, 0).Select
Else
Selection.End(xlDown).Select
End If
ActiveCell.Offset(0, -1).FormulaR1C1 = "1"
Range("A4").Select
ActiveCell.Formula = "=TEXT(D4&E4&B4,""#"")"
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Range("A3").Select
'Update sheet New production orders (PLPODATO)
Sheets("PLPODATO").Select
ActiveSheet.AutoFilterMode = off
Range("A4:K2000").Select
Selection.ClearContents
Selection.Borders.LineStyle = xlNone
Selection.Interior.ColorIndex = xlNone
Selection.Font.Bold = False
Range("A4").Select
Range("D3").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("D3").Select
If ActiveCell.Offset(1, 0) = "" Then
ActiveCell.Offset(2, 0).Select
Else
Selection.End(xlDown).Select
End If
ActiveCell.Offset(0, -1).FormulaR1C1 = "1"
ActiveCell.Offset(0, -2).FormulaR1C1 = "1"
ActiveCell.Offset(0, -3).FormulaR1C1 = "1"
Range("A4").Select
ActiveCell.Formula = "=TEXT(F4&G4&D4,""#"")"
Range("B4").Select
ActiveCell.Formula = "=TEXT(F4&G4&D4&""-""&C4,""#"")"
Range("C4").Select
ActiveCell.Formula = "=IF(H4="""","""",IF(H4=""DK"",""DK"",IF(H4=""PL"",""PL"",IF(H4=""GB"",""UK"",IF(H4=""FR"",""FR"",""Export"")))))"
Range("A4:C4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Range("A3").Select
'Update sheet New order proposals (PLPROPOSAL)
Sheets("PLPROPOSAL").Select
ActiveSheet.AutoFilterMode = off
Range("A4:N2000").Select
Selection.ClearContents
Selection.Borders.LineStyle = xlNone
Selection.Interior.ColorIndex = xlNone
Selection.Font.Bold = False
Range("A4").Select
Range("E3").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("E3").Select
If ActiveCell.Offset(1, 0) = "" Then
ActiveCell.Offset(2, 0).Select
Else
Selection.End(xlDown).Select
End If
ActiveCell.Offset(0, -1).FormulaR1C1 = "1"
ActiveCell.Offset(0, -2).FormulaR1C1 = "1"
ActiveCell.Offset(0, -3).FormulaR1C1 = "1"
ActiveCell.Offset(0, -4).FormulaR1C1 = "1"
Range("A4").Select
ActiveCell.Formula = "=CONCATENATE(D4,""-"",TEXT(B4,""RRRRMMDD""))"
ActiveCell.Offset(0, 1).Formula = "=IF(ISERROR(VLOOKUP(C4,'Non-production'!$A$11:$A$70,1,FALSE)),WORKDAY(C4,0,'Non-production'!$A$10:$A$70),WORKDAY(C4,-1,'Non-production'!$A$10:$A$70))"
ActiveCell.Offset(0, 2).Formula = "=IF(OR(M4=""520"",M4=""540""),WORKDAY(DATE(LEFT(I4,4),MID(I4,5,2),RIGHT(I4,2)),-3,'Non-production'!$A$10:$A$70),DATE(LEFT(I4,4),MID(I4,5,2),RIGHT(I4,2)))"
ActiveCell.Offset(0, 3).Formula = "=G4&H4&E4"
Range("A4
4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Range("A3").Select
'Update sheet Released production orders (PLPOLOAD)
Sheets("PLPOLOAD").Select
ActiveSheet.AutoFilterMode = off
Range("A4
2000").Select
Selection.ClearContents
Selection.Borders.LineStyle = xlNone
Selection.Interior.ColorIndex = xlNone
Selection.Font.Bold = False
Range("A4").Select
Range("C3").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Range("C3").Select
If ActiveCell.Offset(1, 0) = "" Then
ActiveCell.Offset(2, 0).Select
Else
Selection.End(xlDown).Select
End If
ActiveCell.Offset(0, -1).FormulaR1C1 = "1"
ActiveCell.Offset(0, -2).FormulaR1C1 = "1"
Range("A4").Select
ActiveCell.Formula = "=IF(L4<""40"",TEXT(E4&F4&C4&""-""&20&""-""&M4&""-""&O4&""-""&G4,""#""),TEXT(E4&F4&C4&""-""&40&""-""&M4&""-""&O4&""-""&G4,""#""))"
ActiveCell.Offset(0, 1).Formula = "=TEXT(E4&F4&C4&""-""&IF(L4>=""40"",40,IF(L4<""40"",""20"",L4))&""-""&M4&""-""&G4,""#"")"
Range("A4:B4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Range("A3").Select
'Insert todays date and place cursor in correct cell
Sheets("Control").Select
IDAG = Range("A27").Value
Sheets("Information").Select
Range("Q24:Q33").Copy
Range("J23").Select
If ActiveCell = IDAG Then
ActiveCell.Offset(1, 0).Select
ElseIf ActiveCell.Offset(0, 1) = IDAG Then
ActiveCell.Offset(1, 1).Select
ElseIf ActiveCell.Offset(0, 2) = IDAG Then
ActiveCell.Offset(1, 2).Select
ElseIf ActiveCell.Offset(0, 3) = IDAG Then
ActiveCell.Offset(1, 3).Select
ElseIf ActiveCell.Offset(0, 4) = IDAG Then
ActiveCell.Offset(1, 4).Select
Else
ActiveCell.Offset(1, 10).Select
'If weekday is not available, set criteria to run weekchange to 1 (=Active)
If AutoWeekChangeActive = "Yes" Then
RunWeekChange = 1
End If
End If
'Insert totals for produced orders
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("Q39:Q44").Copy
ActiveCell.Offset(15, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Insert totals for order intake
Range("Q52:Q61").Copy
ActiveCell.Offset(13, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Insert totals for order split of order intake
Range("Q67:Q77").Copy
ActiveCell.Offset(15, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'Change week if activated
If RunWeekChange = 1 Then
Call ShowSheets
Call MakeWeekChange
Call HideSheets
End If
Range("A4").Select
'Insert time of updating
Sheets("FB1").Select
Range("C1") = Now
'Hide unneeded shets
Call HideSheets
'Restart screen-updatinga
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub