Hi there,
I have a script which rolls accounting periods from one period into the next keeping the formulas while paste valuing the previous period. The script also excludes certain sheets which are working fine.
However, the script returns an error at the below line (in red bold) on the last sheet and is not finishing out fully. Any ideas why I am getting an error here? The script is doing what i want it to do but is just stopping at this point and running an error.
Many thanks in advance,
Philip
VBA SCRIPT
Sub LastColumn()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "FY17 Input" And ws.Name <> "SSC Working" And ws.Name <> "Will" And ws.Name <> "Michael" Then
ws.Activate
With ws
Range("A1").End(xlToRight).Select
ActiveCell.EntireColumn.Select
ActiveCell.EntireColumn.Copy
ActiveCell.Offset(0, 1).PasteSpecial xlPasteFormulasAndNumberFormats
ActiveCell.Offset(0, -1).Select
ActiveCell.EntireColumn.Select
ActiveCell.EntireColumn.PasteSpecial xlPasteValuesAndNumberFormats
End With
End If
Next ws
ActiveWorkbook.Sheets("Sheet1").Activate
Application.ScreenUpdating = True
End Sub
I have a script which rolls accounting periods from one period into the next keeping the formulas while paste valuing the previous period. The script also excludes certain sheets which are working fine.
However, the script returns an error at the below line (in red bold) on the last sheet and is not finishing out fully. Any ideas why I am getting an error here? The script is doing what i want it to do but is just stopping at this point and running an error.
Many thanks in advance,
Philip
VBA SCRIPT
Sub LastColumn()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "FY17 Input" And ws.Name <> "SSC Working" And ws.Name <> "Will" And ws.Name <> "Michael" Then
ws.Activate
With ws
Range("A1").End(xlToRight).Select
ActiveCell.EntireColumn.Select
ActiveCell.EntireColumn.Copy
ActiveCell.Offset(0, 1).PasteSpecial xlPasteFormulasAndNumberFormats
ActiveCell.Offset(0, -1).Select
ActiveCell.EntireColumn.Select
ActiveCell.EntireColumn.PasteSpecial xlPasteValuesAndNumberFormats
End With
End If
Next ws
ActiveWorkbook.Sheets("Sheet1").Activate
Application.ScreenUpdating = True
End Sub