Running-time error 1004-Invalid Parameter

Joanne tran

New Member
Joined
Jan 13, 2017
Messages
2
Please help me to debug this code. I have been reading this code over and over and can't see why error occurred. Thanks. Look at the red color line.

Function createCharts() ' *****************************************************


Dim pivotSheet As Worksheet
Dim lastRow As Long
Dim chartSheet As Worksheet
Dim wk_adj As Long



' > > > > > lastRow adjusts weeks
wk_adj = Worksheets("Interface").Range("c18")
Set pivotSheet = Sheet2
lastRow = pivotSheet.Range("B" & Rows.Count).End(xlUp).Row - wk_adj
Set chartSheet = Sheet3

' Delete all previous chart objects ----------------------------------------
Dim chtObj As ChartObject
For Each chtObj In chartSheet.ChartObjects
chtObj.Delete
Next
' --------------------------------------------------------------------------


' Chart Objects ------------------------------------------------------------
Dim colLate As Object
Dim colShort As Object
Dim colMed As Object
Dim colLong As Object
Dim colBars As Object
' --------------------------------------------------------------------------


' Chart Dimensions ---------------------------------------------------------
Dim height As Long
Dim baseLeft As Long
Dim baseTop As Long
Dim width As Long
Dim offset As Long

' >>>>>>>>>>>>>>>>>
height = Worksheets("Interface").Range("C11")
baseLeft = Worksheets("Interface").Range("C12")
baseTop = Worksheets("Interface").Range("C13")
width = Worksheets("Interface").Range("C14")
offset = Worksheets("Interface").Range("C15")
' >>>>>>>>>>>>>>>>>


' --------------------------------------------------------------------------


' Create Late --------------------------------------------------------------
Set colLate = chartSheet.ChartObjects.Add(Left:=baseLeft, width:=width, Top:=offset, height:=height)
colLate.chart.SetSourceData Source:=pivotSheet.Range("H2:H" & lastRow)


colLate.Activate
With ActiveChart
.HasTitle = True
.ChartTitle.Text = "Late"
.HasLegend = False
.Axes(xlValue).MaximumScale = 1
.Axes(xlValue).MajorUnit = 0.2
End With

colLate.chart.SeriesCollection([Index]).Interior.Color = RGB(204, 0, 0)
colLate.chart.SeriesCollection(1).HasDataLabels = True
colLate.chart.SeriesCollection(1).DataLabels.NumberFormat = "0%"
colLate.chart.SeriesCollection(1).DataLabels.Interior.Color = RGB(255, 255, 255)
colLate.Name = "colLate"
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,215,361
Messages
6,124,500
Members
449,166
Latest member
hokjock

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top