VB Macros for Charts - Fails (Office 2003 on WInXP Sp2)
Hi,
Cant underatand why some plots go through fine, some fail....this is portion of chart plotting. I didnt specifically want to include a huge vb macro in here. It fails at the line: Source:=Sheets(str2).Range("A1:A290,K1:K290,L1:L29 0") saying subscr out of range. My A, K and L cols have floating point data (in the form of XX.YY) and values start from row#3. So, A(1,1) A(1,2) have column heading (string). Same with K(1,1) K(1,2) and L(1,1) and L(1,2) Sometimes it runs fine. I can plot. Everything is perfect. Some plots are a problem. Don't know why. No data exceeds row# 290. Yes - I have checkd it a hundred times... Thanks. str2 is a string parameter Im passing from another macro. its basically a filename and harmless. same with str3 and str1....if you find them. .... ..... Range("A1").Select Range("A1:A291").Select Range("A1:A291,K1").Select Range("K1").Activate 'Range("A1:A290,K1:K290,L1:L290").Select 'Range("A:A,K:L").Select 'Range("L1").Activate Range("A1:A290,K1:K290,L1:L290").Select Range("L1").Activate Charts.Add ActiveChart.ChartType = xlLineMarkers ActiveChart.SetSourceData Source:=Sheets(str2).Range("A1:A290,K1:K290,L1:L29 0") With ActiveChart .HasTitle = True .ChartTitle.Characters.Text = "xStat vs TMC (Average)" .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Time" .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Speed" End With ' ActiveWorkbook.SaveAs Filename:= _ str3, FileFormat _ :=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _ False, CreateBackup:=False ..... ..... ..... |
VB Macros for Charts - Fails (Office 2003 on WInXP Sp2)
What the error message is telling you is that it can't find a sheet named
str2. So whatever that variable equals is not recognized by VBA as a sheet name nor index number. That is where your problem lies, not in the length of the data in the columns. "Deepak" wrote: Hi, Cant underatand why some plots go through fine, some fail....this is portion of chart plotting. I didnt specifically want to include a huge vb macro in here. It fails at the line: Source:=Sheets(str2).Range("A1:A290,K1:K290,L1:L29 0") saying subscr out of range. My A, K and L cols have floating point data (in the form of XX.YY) and values start from row#3. So, A(1,1) A(1,2) have column heading (string). Same with K(1,1) K(1,2) and L(1,1) and L(1,2) Sometimes it runs fine. I can plot. Everything is perfect. Some plots are a problem. Don't know why. No data exceeds row# 290. Yes - I have checkd it a hundred times... Thanks. str2 is a string parameter Im passing from another macro. its basically a filename and harmless. same with str3 and str1....if you find them. ... .... Range("A1").Select Range("A1:A291").Select Range("A1:A291,K1").Select Range("K1").Activate 'Range("A1:A290,K1:K290,L1:L290").Select 'Range("A:A,K:L").Select 'Range("L1").Activate Range("A1:A290,K1:K290,L1:L290").Select Range("L1").Activate Charts.Add ActiveChart.ChartType = xlLineMarkers ActiveChart.SetSourceData Source:=Sheets(str2).Range("A1:A290,K1:K290,L1:L29 0") With ActiveChart .HasTitle = True .ChartTitle.Characters.Text = "xStat vs TMC (Average)" .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Time" .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Speed" End With ' ActiveWorkbook.SaveAs Filename:= _ str3, FileFormat _ :=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _ False, CreateBackup:=False .... .... .... |
All times are GMT +1. The time now is 04:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com