Hi, I have a pivot table that I'm copying to a new tab to work with as values.
The code below is to copy the entire table and paste special to a new tab after the sheet "Inventory Movement". Then paste special a few time to keep the format. Then create a table from the cells and add 2 columns to the table.
But I get a VBA error "RUN TIME ERROR 1004"
Sub InventoryMovementCopyToNewSheetForReview2()
Dim ws As Worksheet
Dim rng As Range
'
' Copy Inventory Movement tab and create a new worksheet as values only for design and review
'
Range("A4:Z81").Select
Range("A5").Activate
Selection.Copy
Set ws = Worksheets.Add(After:=Sheets("Inventory Movement"))
ws.Name = "Markdown Review " & Format(Date, "mmm_dd")
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$Z$78"), , xlYes).Name = _
"Table11"
Range("Table11[#All]").Select
ActiveSheet.ListObjects("Table11").TableStyle = "TableStyleMedium2"
ActiveWindow.DisplayGridlines = False
Range("AA1").Select
ActiveCell.FormulaR1C1 = "PROPOSSED DISCOUNT"
Range("AB1").Select
ActiveCell.FormulaR1C1 = "COMMENTS"
Columns("AB:AB").Select
Selection.ColumnWidth = 20
End Sub
Also when I review the code above will I have an issue with the table name as I plan on running the VBA all the time to create an additional table for review and keeping the old tables/sheets.
What if my table ranges get bigger will that also be an issue.
The table name in the code above is "Table11", but how can i rerun it as the name would already be used once.
And what if my " ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$Z$78"), , xlYes).Name = _" is longer than line 78?
Thanks
The code below is to copy the entire table and paste special to a new tab after the sheet "Inventory Movement". Then paste special a few time to keep the format. Then create a table from the cells and add 2 columns to the table.
But I get a VBA error "RUN TIME ERROR 1004"
Sub InventoryMovementCopyToNewSheetForReview2()
Dim ws As Worksheet
Dim rng As Range
'
' Copy Inventory Movement tab and create a new worksheet as values only for design and review
'
Range("A4:Z81").Select
Range("A5").Activate
Selection.Copy
Set ws = Worksheets.Add(After:=Sheets("Inventory Movement"))
ws.Name = "Markdown Review " & Format(Date, "mmm_dd")
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$Z$78"), , xlYes).Name = _
"Table11"
Range("Table11[#All]").Select
ActiveSheet.ListObjects("Table11").TableStyle = "TableStyleMedium2"
ActiveWindow.DisplayGridlines = False
Range("AA1").Select
ActiveCell.FormulaR1C1 = "PROPOSSED DISCOUNT"
Range("AB1").Select
ActiveCell.FormulaR1C1 = "COMMENTS"
Columns("AB:AB").Select
Selection.ColumnWidth = 20
End Sub
Also when I review the code above will I have an issue with the table name as I plan on running the VBA all the time to create an additional table for review and keeping the old tables/sheets.
What if my table ranges get bigger will that also be an issue.
The table name in the code above is "Table11", but how can i rerun it as the name would already be used once.
And what if my " ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$Z$78"), , xlYes).Name = _" is longer than line 78?
Thanks
Last edited: