Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to create chart by VBA coding?


Hi all,

I recorded a macro to add a chart, and altered the code shown as
follows:

Sub newChart()
charts.Add
ActiveChart.Location Whe=xlLocationAsObject, Name:="User
Preferences"
With ActiveChart
..SetSourceData Source:=Sheets("User
Preferences").Range("A12").CurrentRegion, PlotBy:=xlColumns
..HasTitle = True
..ChartType = xlColumnClustered
..ChartTitle.Characters.Text = "Interactive Chart Analysis"
..Axes(xlCategory, xlPrimary).HasTitle = True
..Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text =
"Countries"
..Axes(xlValue, xlPrimary).HasTitle = True
..Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Rating"
End With
End Sub

however, while 'Call newChart', error message shows method 'Add' is not
found.

i've checked books and online information, but still couldn't solve it.
can anyone help please? :(

Thanks
Fendic


--
Fendic
------------------------------------------------------------------------
Fendic's Profile: http://www.excelforum.com/member.php...o&userid=23959
View this thread: http://www.excelforum.com/showthread...hreadid=380441

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to create chart by VBA coding?


Fendic it works for me, can you zip your excel file and attach to thi
pos

--
anilsolipura
-----------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...fo&userid=1627
View this thread: http://www.excelforum.com/showthread.php?threadid=38044

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to create chart by VBA coding?


i am afraid, the project is related to a huge database, and I don't
think i am allowed to attach it together. + the code i wrote is exact
the same as I posted. and I simply call the methed as:

Call newChart

Does it need to include some library or anything? i really got
confused. Can anyone help pleeeeeeeeeeeeease? :(


--
Fendic
------------------------------------------------------------------------
Fendic's Profile: http://www.excelforum.com/member.php...o&userid=23959
View this thread: http://www.excelforum.com/showthread...hreadid=380441

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to create chart by VBA coding?


You can test your code with new workbook, open new excel workbook, paste
your macro code in vba editor, make sure you have text in cell A12

Test it and let me know

Sub newChart()
Charts.Add
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
..SetSourceData Source:=Sheets("Sheet1").Range("A12").CurrentRegio n,
PlotBy:=xlColumns
..HasTitle = True
..ChartType = xlColumnClustered
..ChartTitle.Characters.Text = "Interactive Chart Analysis"
..Axes(xlCategory, xlPrimary).HasTitle = True
..Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Countries"
..Axes(xlValue, xlPrimary).HasTitle = True
..Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Rating"
End With
End Sub


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=380441

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to create chart by VBA coding?


Hi Anilsolipuram,

I tried in a new worksheet and it works. It seems the problem is the
code generated by Macro in my project cannot find the source data. I
tried activate the object worksheet in front of the Charts.Add as:

ActiveWorkbook.Sheets("User Preferences").Activate

and still doesn't work. i must be sth wrong with identifying the source
data. Just don't know how....

oh btw, each time you reply my question as soon as i post it. I really
really appreciate your help. Thanks:)


--
Fendic
------------------------------------------------------------------------
Fendic's Profile: http://www.excelforum.com/member.php...o&userid=23959
View this thread: http://www.excelforum.com/showthread...hreadid=380441



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to create chart by VBA coding?


Hi Anilsolipuram,

i tried everything the same in a blank workbook, and it works
brilliant. how come it's not working in my proj? i can't think of
anything, can you?

Thanks
Fendic :(


--
Fendic
------------------------------------------------------------------------
Fendic's Profile: http://www.excelforum.com/member.php...o&userid=23959
View this thread: http://www.excelforum.com/showthread...hreadid=380441

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to create chart by VBA coding?


Hi Anilsolipuram and everyone,

it's just sorted in the last 2 mins. i couldn't believe it's just
because of losing a single word. the code should be as follows:

ThisWorkbook.charts.Add

or

ActiveWorkbook.charts.Add

maybe cos i just started to learn vba last month and only look for sth
while needed, so that i would got stuck for such a small fault.

anyway, thank you Anilsolipuram and thank you everyone for you notice.

All the best ;)
Fendic


--
Fendic
------------------------------------------------------------------------
Fendic's Profile: http://www.excelforum.com/member.php...o&userid=23959
View this thread: http://www.excelforum.com/showthread...hreadid=380441

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
create line chart with two axises in Pivot Chart HuaXC Charts and Charting in Excel 1 February 21st 07 08:28 PM
Chart data file lost - need to re-create from chart? LostExcelData Charts and Charting in Excel 1 June 7th 06 07:54 PM
How to see the chart coding? ramkumar_cpt Charts and Charting in Excel 1 March 10th 06 12:12 PM
Need help with data from coding....try to create an update button marty6[_10_] Excel Programming 2 May 4th 04 06:19 PM
Excel Chart Event Coding ramkee27 Excel Programming 0 February 20th 04 02:59 PM


All times are GMT +1. The time now is 05:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"