Hello I know there are other forums on this but rule says to start new thread with my problems. Plus I am new to this. I have a single worksheet that i want to print out with a number on top that increases by one with each copy with out having to change that number myself. I tryed the following code but got the error below that Follows.
And get this error: ActiveSheet.ChartObjects("Chart 3").Activate. I don't know how to fix it.
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim nCounter As Integer
nCounter = Sheets("PrintCounter").Range("F1").Value
With ActiveSheet.PageSetup
.CenterFooter = "Certificate #" & Format(nCounter, "0000")
End With
nCounter = nCounter + 1
Sheets("PrintCounter").Range("F1").Value = nCounter
End Sub
Code:
Sub Serialnumber()
'
' Serialnumber Macro
' Serial number counter
'
' Keyboard Shortcut: Ctrl+z
'
Range("F1").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Range("'New Part Setup Form'!$A$1:$F$5")
Range("F1").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Range("'New Part Setup Form'!$A$1:$F$5")
ActiveChart.PlotArea.Select
ActiveChart.Legend.Select
ActiveChart.ChartArea.Select
ActiveChart.Parent.Delete
ActiveSheet.ChartObjects("Chart 3").Activate
ActiveChart.Parent.Delete
Range("D1").Select
ActiveCell.FormulaR1C1 = "10"
Range("F1").Select
ChDir "E:\Work\Projects\Machine control"
End Sub