Hi,
Newbie here, I have a Macro that I have recorded to copy and paste some data into a sheet, which runs just fine, until I hide a couple of worksheets. I have searched and found that I shouldnt select the worksheets?!? How do I not select what I need to copy?
I'm also trying to make it so that the list of column autosizing that I have at the end is in one command, I have tried changing columns("D:D").entirecolumn.autofit to columns("D:D", "G:G").entirecolumn.autofit, but this throws up an error, so any help on this as well would be greatly appreciated.
Plus if you see anything else that can be simplified feel free to shout!
Thanks in advance from an amateur.
Newbie here, I have a Macro that I have recorded to copy and paste some data into a sheet, which runs just fine, until I hide a couple of worksheets. I have searched and found that I shouldnt select the worksheets?!? How do I not select what I need to copy?
I'm also trying to make it so that the list of column autosizing that I have at the end is in one command, I have tried changing columns("D:D").entirecolumn.autofit to columns("D:D", "G:G").entirecolumn.autofit, but this throws up an error, so any help on this as well would be greatly appreciated.
Plus if you see anything else that can be simplified feel free to shout!
Code:
Sheets("Paste Special").Select
Cells.Select
Selection.ClearContents
Range("A1").Select
Sheets("Lookup").Select
Range("A3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Paste Special").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Paste Special").Select
ActiveWindow.SmallScroll Down:=-54
Sheets("Pivot").Select
Range("C6").Select
Application.CutCopyMode = False
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
Columns("B:B").ColumnWidth = 14.14
Columns("C:C").ColumnWidth = 12.86
Columns("D:D").EntireColumn.AutoFit
Columns("E:E").ColumnWidth = 12.86
Columns("F:F").ColumnWidth = 14
Columns("G:G").EntireColumn.AutoFit
Columns("H:H").ColumnWidth = 15.14
Columns("I:I").EntireColumn.AutoFit
Columns("J:J").EntireColumn.AutoFit
Columns("K:K").ColumnWidth = 14.57
Columns("L:L").ColumnWidth = 14.29
Columns("M:M").EntireColumn.AutoFit
Columns("N:N").EntireColumn.AutoFit
Columns("O:O").EntireColumn.AutoFit
Columns("P:P").EntireColumn.AutoFit
Columns("Q:Q").EntireColumn.AutoFit
Columns("R:R").EntireColumn.AutoFit
Columns("S:S").EntireColumn.AutoFit
Columns("T:T").EntireColumn.AutoFit
Range("B5").Select
ActiveWindow.FreezePanes = True
Thanks in advance from an amateur.