fares paris
New Member
- Joined
- Jun 5, 2013
- Messages
- 3
I'm curently working in a workbook where data from other sheets are copied onto, after having recieved all the data (wich are of variable legth) the macro adds a Time column, previously left blak, and then generates a chart. I ran the code in several pieces and using the method above I end up with an error 13 on my chart function, I'm not sure the error comes from. could any one advise me on the path to follow?
Code:
Sub t_feuille(f_Work As Worksheet)
Dim num_line As Integer, t_Work As Worksheet
Dim myrange As Range
'instals time column
f_Work.Activate
f_Work.Cells(1, 1) = "Time"
For num_line = 2 To last_line(t_Work)
f_Work.Cells(num_line, 1) = num_line - 2
Next
'graph set up
Set myrange = ActiveSheet.Cells(1, 1).CurrentRegion
Application.CutCopyMode = False
ActiveChart.ChartWizard _
Source:=Sheets(f_Work).Range(myrange), _
Gallery:=xlXYScatterSmoothNoMarkers, Format:=4, PlotBy:=xlColumns, _
CategoryLabels:=1, SeriesLabels:=1, HasLegend:=1, _
Title:=f_Work, CategoryTitle:="", _
ValueTitle:="", ExtraTitle:=""
End Sub
Function last_line(f_Work) As Integer
Dim num_col As Integer, num_line As Integer
num_line = 0
For num_col = 1 To ActiveSheet.Cells(1, 10000).End(xlToLeft).Column
If ActiveSheet.Cells(100000, num_col).End(xlUp).Row > num_line Then
num_line = ActiveSheet.Cells(100000, num_col).End(xlUp).Row
End If
Next
last_line = num_line
End Function