Autofill Type Mismatch Error

mraemorris

New Member
Joined
Mar 7, 2014
Messages
2
Hi all,

This is my first post, so please let me know if you need more info! I'm using Excel 2010 and I wrote the code below to autofill a range that feeds a chart on the worksheet "Dashboard." Essentially, the user selects criteria on the Dashboard and clicks the "Submit" button, which causes an advanced filter to copy the data that matches the criteria into the range Sheets("HiddenSheet").Range("A2:H"). I need the code below to autofill the formulas in I3:Q3 in I:Q until the last row in A:H, but I keep getting a "Type Mismatch" error on the bolded line below. I've searched everywhere to remedy this, and I've tried several different iterations of both the range and lastrow - any suggestions would be greatly appreciated!

One note - Columns K:Q contain formulas that feed off of Column C and into Column J - that's why the autofill range is different than the chart SetSourceData range.



Sub TimelineControl()


Dim Timeline As Chart
Dim ws As Worksheet
Dim rngforTimeline As Range
Dim LastAxis As Integer
Dim LastA As Long


Set ws = Sheets("HiddenSheet")
LastA = ws.Range("A" & Rows.Count).End(xlUp).Row
'LastA = ws.Range("A1").End(xlDown).Row
'LastA = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
LastAxis = ws.Cells(Rows.Count, 9).End(xlUp).Row


Set rngforTimeline = ws.Range("I3:Q" & LastA)


ws.Range("I4:Q" & (ws.Range("Q" & Rows.Count).End(xlUp).Row) + 1).Clear
ws.Range("I3:Q3").AutoFill Destination = rngforTimeline


Set Timeline = Sheets("Dashboard").ChartObjects(1).Chart
Timeline.SetSourceData (Sheets("HiddenSheet").Range("I3:J" & LastAxis))


End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi and welcome to the forum,

Looks like your missing a colon after 'Destination'. Maybe try:

Code:
ws.Range("I3:Q3").AutoFill Destination:=rngforTimeline
 
Upvote 0
Hi and welcome to the forum,

Looks like your missing a colon after 'Destination'. Maybe try:

Code:
ws.Range("I3:Q3").AutoFill Destination:=rngforTimeline

Thank you! I wasted an embarrassing amount of time on that...

I'm now getting an error on the Timeline.SetSourceData line (1004 - Application-defined or object-defined error). I'm off to work on that, but if you have any suggestions they're more than welcome!
 
Upvote 0
I'm no sure. What is the value of the LastAxis variable when the error occurs?

Maybe try:

Code:
Timeline.SetSourceData Source:=ws.Range("I3:J" & LastAxis)
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

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