当我开始将数据输入Chair_Orders
表格时,我突然开始收到此错误...
名称“Chair_Orders”已存在。单击是以使用该版本的名称,或单击否以重命名您正在移动或复制的“Chair_Orders”版本。
如果我去名称管理员,则没有冲突。
我尝试使用表工具转到表本身,并将表重命名为Chair_Orders2
,现在我没有冲突,但如果我尝试将其更改回来,我会收到错误消息Chair_Orders
已存在且必须是唯一的。
我有一堆VBA引用Chair_Orders
所以我真的需要改回来。有没有办法找到冲突?
这是我的代码......
Sub Print_Worksheet()
'Set Paper Size
Worksheets("Chair Orders").PageSetup.PaperSize = xlPaperLetter
'Clear defined print area
Worksheets("Chair Orders").PageSetup.PrintArea = ""
'Remove all filters
Worksheets("Chair Orders").ListObjects("Chair_Orders").AutoFilter.ShowAllData
'Filter out upholstered orders
'Worksheets("Chair Orders").ListObjects("Chair_Orders").Range.AutoFilter Field:=14, _
Criteria1:="="
'Filter out Shipped Items - Not everything gets upholstered... Old inventory etc.
Worksheets("Chair Orders").ListObjects("Chair_Orders").Range.AutoFilter Field:=17, _
Criteria1:="="
'Sort by Must Ship Date
Dim ws As Worksheet
Set ws = ActiveSheet
Dim tbl As ListObject
Set tbl = ws.ListObjects("Chair_Orders")
Dim sortcolumn As Range
Set sortcolumn = Range("Chair_Orders[Must Ship By]")
With tbl.Sort
.SortFields.Clear
.SortFields.Add Key:=sortcolumn, SortOn:=xlSortOnValues, Order:=xlAscending
.Header = xlYes
.Apply
End With
'Hide cells we don't want to print
Worksheets("Chair Orders").Range("I:I").EntireColumn.Hidden = True
Worksheets("Chair Orders").Range("Q:BZ").EntireColumn.Hidden = True
'Setup page to print fit
'With Worksheets("Chair Orders").PageSetup
' .Zoom = False
' .FitToPagesTall = 1
' .FitToPagesWide = 1
'End With
With Worksheets("Chair Orders").PageSetup
.Zoom = 46
End With
'Remove shading from printouts
Worksheets("Chair Orders").PageSetup.BlackAndWhite = True
'Print the worksheet
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=2, Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
'Show the hidden cells again
Worksheets("Chair Orders").Range("A:BZ").EntireColumn.Hidden = False
Call Reset_Filters
End Sub
Sub View_Schedule()
Call Reset_Filters
'Sort by Must Ship Date
Dim ws As Worksheet
Set ws = ActiveSheet
Dim tbl As ListObject
Set tbl = ws.ListObjects("Chair_Orders")
Dim sortcolumn As Range
Set sortcolumn = Range("Chair_Orders[Must Ship By]")
With tbl.Sort
.SortFields.Clear
.SortFields.Add Key:=sortcolumn, SortOn:=xlSortOnValues, Order:=xlAscending
.Header = xlYes
.Apply
End With
'Unhide all columns
Worksheets("Chair Orders").Range("A:BZ").EntireColumn.Hidden = False
'Hide cells we don't want to print
Worksheets("Chair Orders").Range("A:A").EntireColumn.Hidden = True
Worksheets("Chair Orders").Range("G:J").EntireColumn.Hidden = True
Worksheets("Chair Orders").Range("L:T").EntireColumn.Hidden = True
Worksheets("Chair Orders").Range("V:X").EntireColumn.Hidden = True
Worksheets("Chair Orders").Range("AG:BZ").EntireColumn.Hidden = True
End Sub
Sub View_EOD()
Call Reset_Filters
'Sort by Must Ship Date
Dim ws As Worksheet
Set ws = ActiveSheet
Dim tbl As ListObject
Set tbl = ws.ListObjects("Chair_Orders")
Dim sortcolumn As Range
Set sortcolumn = Range("Chair_Orders[Sales Order]")
With tbl.Sort
.SortFields.Clear
.SortFields.Add Key:=sortcolumn, SortOn:=xlSortOnValues, Order:=xlAscending
.Header = xlYes
.Apply
End With
'Unhide all columns
Worksheets("Chair Orders").Range("A:BZ").EntireColumn.Hidden = False
'Hide cells we don't want to print
Worksheets("Chair Orders").Range("A:B").EntireColumn.Hidden = True
Worksheets("Chair Orders").Range("F:G").EntireColumn.Hidden = True
Worksheets("Chair Orders").Range("P:BZ").EntireColumn.Hidden = True
End Sub
Sub Update_Invoice()
Call Reset_Filters
'Sort by Must Ship Date
Dim ws As Worksheet
Set ws = ActiveSheet
Dim tbl As ListObject
Set tbl = ws.ListObjects("Chair_Orders")
Dim sortcolumn As Range
Set sortcolumn = Range("Chair_Orders[Sales Order]")
With tbl.Sort
.SortFields.Clear
.SortFields.Add Key:=sortcolumn, SortOn:=xlSortOnValues, Order:=xlAscending
.Header = xlYes
.Apply
End With
'Unhide all columns
Worksheets("Chair Orders").Range("A:BZ").EntireColumn.Hidden = False
'Hide cells we don't want to print
Worksheets("Chair Orders").Range("A:B").EntireColumn.Hidden = True
Worksheets("Chair Orders").Range("F:G").EntireColumn.Hidden = True
Worksheets("Chair Orders").Range("S:BZ").EntireColumn.Hidden = True
End Sub
Sub Print_Schedule()
'Set Paper Size
Worksheets("Chair Orders").PageSetup.PaperSize = xlPaperLetter
'Clear defined print area
Worksheets("Chair Orders").PageSetup.PrintArea = ""
'Remove all filters
Worksheets("Chair Orders").ListObjects("Chair_Orders").AutoFilter.ShowAllData
'Filter out upholstered orders
'Worksheets("Chair Orders").ListObjects("Chair_Orders").Range.AutoFilter Field:=14, _
Criteria1:="="
'Filter out Shipped Items - Not everything gets upholstered... Old inventory etc.
Worksheets("Chair Orders").ListObjects("Chair_Orders").Range.AutoFilter Field:=17, _
Criteria1:="="
'Sort by Must Ship By Date then UPH Date
ActiveWorkbook.Worksheets("Chair Orders").ListObjects("Chair_Orders").Sort. _
SortFields.Clear
ActiveWorkbook.Worksheets("Chair Orders").ListObjects("Chair_Orders").Sort. _
SortFields.Add Key:=Range("Chair_Orders[Must Ship By]"), SortOn:= _
xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Chair Orders").ListObjects("Chair_Orders").Sort. _
SortFields.Add Key:=Range("Chair_Orders[UPH DATE]"), SortOn:=xlSortOnValues _
, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Chair Orders").ListObjects("Chair_Orders").Sort. _
SortFields.Add Key:=Range("Chair_Orders[UPHOLSTERER]"), SortOn:=xlSortOnValues _
, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Chair Orders").ListObjects("Chair_Orders").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Sort by Must Ship By Date
'Dim ws As Worksheet
'Set ws = ActiveSheet
'Dim tbl As ListObject
'Set tbl = ws.ListObjects("Chair_Orders")
'Dim sortcolumn As Range
'Set sortcolumn = Range("Chair_Orders[Must Ship By]")
'With tbl.Sort
' .SortFields.Clear
' .SortFields.Add Key:=sortcolumn, SortOn:=xlSortOnValues, Order:=xlAscending
' .Header = xlYes
' .Apply
'End With
'Unhide all columns
Worksheets("Chair Orders").Range("A:BZ").EntireColumn.Hidden = False
'Hide cells we don't want to print
Worksheets("Chair Orders").Range("A:A").EntireColumn.Hidden = True
Worksheets("Chair Orders").Range("G:T").EntireColumn.Hidden = True
Worksheets("Chair Orders").Range("V:X").EntireColumn.Hidden = True
Worksheets("Chair Orders").Range("AG:BZ").EntireColumn.Hidden = True
'Setup page to print fit
'With Worksheets("Chair Orders").PageSetup
' .Zoom = False
' .FitToPagesTall = 1
' .FitToPagesWide = 1
'End With
With Worksheets("Chair Orders").PageSetup
.Zoom = 46
End With
'Remove shading from printouts
Worksheets("Chair Orders").PageSetup.BlackAndWhite = True
'Print the worksheet
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=2, Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
'Show the hidden cells again
Worksheets("Chair Orders").Range("A:BZ").EntireColumn.Hidden = False
Call Reset_Filters
End Sub
Sub Reset_Filters()
'Set formatting
Call Copy_Formatting
'Unhide all columns
Worksheets("Chair Orders").Range("A:BZ").EntireColumn.Hidden = False
'Remove all filters
Worksheets("Chair Orders").ListObjects("Chair_Orders").AutoFilter.ShowAllData
'Filter out Invoiced Items
Worksheets("Chair Orders").ListObjects("Chair_Orders").Range.AutoFilter Field:=18, _
Criteria1:="="
'Sort by Must Ship Date
Dim ws As Worksheet
Set ws = ActiveSheet
Dim tbl As ListObject
Set tbl = ws.ListObjects("Chair_Orders")
Dim sortcolumn As Range
Set sortcolumn = Range("Chair_Orders[Must Ship By]")
With tbl.Sort
.SortFields.Clear
.SortFields.Add Key:=sortcolumn, SortOn:=xlSortOnValues, Order:=xlAscending
.Header = xlYes
.Apply
End With
End Sub
Sub Copy_Formatting()
Application.CutCopyMode = False
'Remove all filters
Worksheets("Chair Orders").ListObjects("Chair_Orders").AutoFilter.ShowAllData
'Copy formatting from the first row
Range("A11:AF11").Select
Selection.Copy
'Paste Formatting
Range("Chair_Orders[[DATE]:[QCER]]").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub
Sub Save_and_Close()
Call Reset_Filters
Worksheets("Chair Orders").Range("A1").Select
'Close the extra window if it is open
On Error Resume Next
Windows("Production Planner.xlsm:2").Close
On Error GoTo 0
Worksheets("Chair Orders").Range("A1").Select
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
答案 0 :(得分:0)
ExecuteExcel4Macro "SUM(DELETE.NAME(NAMES()))"