Update Values Keeps Popping Up In Macro

liferg

Board Regular
Joined
May 21, 2013
Messages
88
When I run my macro in excel 2007, I keep getting this window to pop up to update value: Sheets 9 and it pops up several times. Each time I hit cancel, and then another one will pop up right after. How can I eliminate this from happening in the coding?

Code:
Sheets("Sheet9").Select</SPAN>
Cells(3, 1).Select</SPAN>
With ActiveSheet.PivotTables("PivotTable1").PivotFields("PO#")</SPAN>
.Orientation = xlRowField</SPAN>
.Position = 1</SPAN>
End With</SPAN>
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _</SPAN>
"PivotTable1").PivotFields("TCSTDIF1"), "Sum of TCSTDIF1", xlSum</SPAN>
With ActiveSheet.PivotTables("PivotTable1").PivotFields("IOSUPR")</SPAN>
ActiveSheet.PivotTables("PivotTable1").PivotFields("IOSUPR").Subtotals = Array( _</SPAN>
False, False, False, False, False, False, False, False, False, False, False, False)</SPAN>
ActiveSheet.PivotTables("PivotTable1").PivotFields("IOSUPR").LayoutForm = _</SPAN>
xlTabular</SPAN>
With ActiveSheet.PivotTables("PivotTable1").PivotFields("ISVNNO")</SPAN>
.Orientation = xlRowField</SPAN>
.Position = 2</SPAN>
End With</SPAN>
ActiveSheet.PivotTables("PivotTable1").PivotFields("ISVNNO").Subtotals = Array( _</SPAN>
False, False, False, False, False, False, False, False, False, False, False, False)</SPAN>
ActiveSheet.PivotTables("PivotTable1").PivotFields("ISVNNO").LayoutForm = _</SPAN>
xlTabular</SPAN>
ActiveSheet.PivotTables("PivotTable1").PivotFields("PO#").Subtotals = Array( _</SPAN>
False, False, False, False, False, False, False, False, False, False, False, False)</SPAN>
ActiveSheet.PivotTables("PivotTable1").PivotFields("PO#").LayoutForm = _</SPAN>
xlTabular</SPAN>
.Orientation = xlRowField</SPAN>
.Position = 2</SPAN>
Range("E4").Select</SPAN>
ActiveCell.FormulaR1C1 = _</SPAN>
"=IF(AND(RC[-3]<>RC[-2],RC[-1]=0),""CHECK PO MANUALLY(BILLED PER PO)"",IF(AND(RC[-3]<>RC[-2],RC[-1]>-100,RC[-1]<100),""CHECK PO MANUALLY(UNDER TOL)"",IF(AND(RC[-3]<>RC[-2],RC[-1]<-100),""CHECK PO MANUALLY(UNDER TOL)"",IF(AND(RC[-3]<>RC[-2],RC[-1]<-100),""CHECK PO MANUALLY(CB@PE)"",IF(AND(RC[-3]<>RC[-2],RC[-1]>100),""CHECK PO MANUALLY(BILLED LESS)"",IF(RC[-1]=0,""BILLED PER PO"",IF(AND(RC[-1]>-100,RC[-1]<100),""UNDER TOL"",IF(RC[-1]<-100,""CB@PE"",IF(RC[-1]>100,""BILLED LESS"","""")))))))))"</SPAN>
Range("E4").Select</SPAN>
Selection.AutoFill Destination:=Range("E4:E1700")</SPAN>
Range("E4:E1700").Select</SPAN>
Columns("E:E").EntireColumn.AutoFit</SPAN>
Range("A4").Select</SPAN>
Sheets.Add After:=Sheets(Sheets.Count)</SPAN>
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _</SPAN>
"ODBC;DSN=AS400_CCOX;", Destination:=Range("$A$1")).QueryTable</SPAN>
.CommandText = Array( _</SPAN>
"SELECT LORFERG.CBNUM, LORFERG.CBIVDT, LORFERG.CBCLNM, LORFERG.CBVNNO, LORFERG.CBINV1, LORFERG.CBIDT1, LORFERG.CBPONM, LORFERG.CDSKU, LORFERG.CDMFG, LORFERG.CDRQTY, LORFERG.CDIQTY, LORFERG.CDQDIF, LORF" _</SPAN>
, _</SPAN>
"ERG.CDRUNT, LORFERG.CDIUNT, LORFERG.CBSAMT, LORFERG.CBLCQF, LORFERG.CBAMT, LORFERG.CBNUML, LORFERG.CBCOMM" & Chr(13) & "" & Chr(10) & "FROM ADVANCE1.CCOX.LORFERG LORFERG" _</SPAN>
)</SPAN>
.RowNumbers = False</SPAN>
.FillAdjacentFormulas = False</SPAN>
.PreserveFormatting = True</SPAN>
.RefreshOnFileOpen = False</SPAN>
.BackgroundQuery = True</SPAN>
.RefreshStyle = xlInsertDeleteCells</SPAN>
.SavePassword = False</SPAN>
.SaveData = True</SPAN>
.AdjustColumnWidth = True</SPAN>
.RefreshPeriod = 0</SPAN>
.PreserveColumnInfo = True</SPAN>
.ListObject.DisplayName = "Table_Query_from_AS400_CCOX10"</SPAN>
.Refresh BackgroundQuery:=False</SPAN>
End With</SPAN>
Selection.AutoFilter</SPAN>
ActiveSheet.ListObjects("Table_Query_from_AS400_CCOX10").Range.AutoFilter _</SPAN>
Field:=1, Criteria1:="=*BAR", Operator:=xlAnd</SPAN>
Rows("2:2").Select</SPAN>
Range(Selection, Selection.End(xlDown)).Select</SPAN>
Selection.Delete Shift:=xlUp</SPAN>
ActiveWorkbook.Worksheets("Sheet10").ListObjects( _</SPAN>
"Table_Query_from_AS400_CCOX10").Sort.SortFields.Clear</SPAN>
ActiveSheet.ShowAllData</SPAN>
ActiveSheet.ListObjects("Table_Query_from_AS400_CCOX10").Range.AutoFilter _</SPAN>
Field:=1, Criteria1:="=*F340", Operator:=xlAnd</SPAN>
Rows("2:2").Select</SPAN>
Range(Selection, Selection.End(xlDown)).Select</SPAN>
Selection.Delete Shift:=xlUp</SPAN>
Range("Table_Query_from_AS400_CCOX10[[#Headers],[CBNUM]]").Select</SPAN>
Selection.AutoFilter</SPAN>
Selection.AutoFilter</SPAN>
ActiveSheet.ListObjects("Table_Query_from_AS400_CCOX10").Range.AutoFilter _</SPAN>
Field:=1, Criteria1:="=*C000", Operator:=xlAnd</SPAN>
Rows("11:11").Select</SPAN>
Range(Selection, Selection.End(xlDown)).Select</SPAN>
Selection.ClearContents</SPAN>
Selection.Delete Shift:=xlUp</SPAN>
Range("Table_Query_from_AS400_CCOX10[[#Headers],[CBNUM]]").Select</SPAN>
Selection.AutoFilter</SPAN>
Range("Table_Query_from_AS400_CCOX10[[#Headers],[CBNUM]]").Select</SPAN>
Selection.AutoFilter</SPAN>
ActiveSheet.ListObjects("Table_Query_from_AS400_CCOX10").Range.AutoFilter _</SPAN>
Field:=1, Criteria1:="=*F800", Operator:=xlAnd</SPAN>
Rows("1277:1277").Select</SPAN>
Range(Selection, Selection.End(xlDown)).Select</SPAN>
Selection.Delete Shift:=xlUp</SPAN>
Range("Table_Query_from_AS400_CCOX10[[#Headers],[CBNUM]]").Select</SPAN>
Selection.AutoFilter</SPAN>
Selection.AutoFilter</SPAN>
ActiveSheet.ListObjects("Table_Query_from_AS400_CCOX10").Range.AutoFilter _</SPAN>
Field:=1</SPAN>
Selection.AutoFilter</SPAN>
ActiveSheet.ListObjects("Table_Query_from_AS400_CCOX10").TableStyle = ""</SPAN>
Selection.AutoFilter</SPAN>
ActiveWorkbook.Worksheets("Sheet10").ListObjects("Table_Query_from_AS400_CCOX10" _</SPAN>
).Sort.SortFields.Clear</SPAN>
ActiveWorkbook.Worksheets("Sheet10").ListObjects("Table_Query_from_AS400_CCOX10" _</SPAN>
).Sort.SortFields.Add Key:=Range("Table_Query_from_AS400_CCOX10[CBPONM]"), _</SPAN>
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal</SPAN>
With ActiveWorkbook.Worksheets("Sheet10").ListObjects( _</SPAN>
"Table_Query_from_AS400_CCOX10").Sort</SPAN>
.Header = xlYes</SPAN>
.MatchCase = False</SPAN>
.Orientation = xlTopToBottom</SPAN>
.SortMethod = xlPinYin</SPAN>
.Apply</SPAN>
End With</SPAN>
ActiveSheet.Range("Table_Query_from_AS400_CCOX10[#All]").RemoveDuplicates _</SPAN>
Columns:=7, Header:=xlYes</SPAN>
Range(Selection, Selection.End(xlToRight)).Select</SPAN>
Range(Selection, Selection.End(xlDown)).Select</SPAN>
Sheets.Add</SPAN>
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _</SPAN>
"Sheet10!R1C1:R78987C19", Version:=xlPivotTableVersion12).CreatePivotTable _</SPAN>
TableDestination:="Sheet11!R3C1", TableName:="PivotTable2", DefaultVersion _</SPAN>
:=xlPivotTableVersion12
</SPAN>
 
Last edited by a moderator:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Try this near the top of the code

Code:
Application.DisplayAlerts = False

Set it to True before End Sub
 
Upvote 0
I tried that and it did not work. The windows are still coming up. Even when I hit cancel, it's not doing any of the steps and throwing off the rest of macro and causing it to error out. Do you have any other suggestions?
 
Upvote 0

Forum statistics

Threads
1,214,533
Messages
6,120,076
Members
448,943
Latest member
sharmarick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top