Computing.Net > Forums > Programming > Excel VBA 1004

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Excel VBA 1004

Reply to Message Icon

Name: tolgasengel
Date: August 14, 2003 at 00:20:41 Pacific
OS: Windows
CPU/Ram: Intel Pentium 2.66 - 256
Comment:

I am trying to create charts for repeatative columns in a sheet. I wrote the following code:

Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("500Ml").Range("B + CStr(i + 3):AB + CStr(i + 6)").Select, PlotBy:=xlRows
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=Total!R3C3:R3C28"
ActiveChart.SeriesCollection(2).XValues = "=Total!R3C3:R3C28"
ActiveChart.SeriesCollection(3).XValues = "=Total!R3C3:R3C28"
ActiveChart.SeriesCollection(4).XValues = "=Total!R3C3:R3C28"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Total"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = Sheet4.Cells((CStr(i) - 1) * 6 + 4, 1) + "-500 ml"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With


The third line starting with "ActiveChart.SetSourceData Source...." gives the error message: Run-time error 1004. Application-defined or object-defined error. I checked the microsoft support link for this error but it didn't solve my problem.

http://support.microsoft.com/default.aspx?kbid=159957

Please help me out. I have a deadline to meet, soon....:(



Sponsored Link
Ads by Google

Response Number 1
Name: Chi Happens
Date: August 14, 2003 at 05:48:27 Pacific
Reply:

Where do you come from, Fortran/Pascal backgound? Your SetSourceData line looks a heck of a lot like Pascal...so [BUZZER] it aint vba.

it should look like this:

ActiveChart.SetSourceData Sheets("500Ml").Range("B" & CStr(i + 3) & ":AB" & CStr(i + 6)).Select, xlRows

Here are the problems:
1) your strings in vb do not parse through like Perl does. So you must enclose the strings within double quotes, not the commands too.
2) VB uses the ampersand to concatenate strings, not the plus sign (most other languages do use the plus sign) so all your + need to be &
3) When you send variables through a function/procedure call in vb, you do NOT include the variable names followed by := (very pascalish) so your calls freak out when you use them like this.

I did not run the program, so i don't know what else you might encounter, but this should help you start. Let me know if this helps at all

Later,
Chi Happens


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Excel VBA 1004

Excel VBA Problem saving file www.computing.net/answers/programming/excel-vba-problem-saving-file-/14722.html

excel vba macro assistance www.computing.net/answers/programming/excel-vba-macro-assistance/10837.html

Excel-VBA problem www.computing.net/answers/programming/excelvba-problem/3695.html