Adding Comments From Cells To Chart Points.

Hi all I have spent a large portion of my weekend trying to find the
answer to this.  Without much luck!  I have finally come up with my
own code and was hoping someone could have a look at it.  I'm looking
to clean it up and make it a little more efficient.

Thanks in advance,
Greg.

Sub AddCommentsToChartPoints()
Dim ws As Worksheet
Dim ct As ChartObject
Dim serSeries As SeriesCollection
Dim ser As Series
Dim Counter As Integer
Dim ChartName As String
Dim xVals As String
Dim xAddress As String
            
'Loop through each worksheet in workbook
For Each ws In Worksheets
    'Loop through each chart in worksheet
    For Each ct In ws.ChartObjects
        'Loop through each series in chart
        For Each ser In ct.Chart.SeriesCollection
            'Store the formula for the first series in xVals
            xVals = ser.Formula
            'Extract the range for the data from xVals
            xVals = Mid(xVals, InStr(InStr(xVals, ","), xVals,
Mid(Left(xVals, InStr(xVals, "!") - 1), 9)))
            xVals = Left(xVals, InStr(InStr(xVals, "!"), xVals, ",") -
1)
            Do While Left(xVals, 1) = ","
                xVals = Mid(xVals, 2)
            Loop
            'Attach a label to each data point in the chart
            For Counter = 1 To Range(xVals).Cells.Count
                ser.Points(Counter).HasDataLabel = True
                'Get cell address of each point
                xAddress = Range(xVals).Cells(Counter, 2).Address
                If Range(xAddress).Comment Is Nothing Then
                    'Null label if no comment
                    ser.Points(Counter).DataLabel.Text = ""
                Else
                    'Add Comment as label
                    ser.Points(Counter).DataLabel.Text =
Range(xAddress).Comment.Text
                End If
            Next Counter
        Next ser
    Next ct
Next ws

End Sub
0
lowegreg (2)
6/20/2004 10:05:54 PM
excel.misc 78881 articles. 5 followers. Follow

2 Replies
699 Views

Similar Articles

[PageSpeed] 49

Hi!

First thing to note is it works. I haven't tested it strenuously, bu
what I have tried worked.

So what do you think it lacks/suffers from ?

Al

--
Message posted from http://www.ExcelForum.com

0
6/20/2004 11:17:32 PM
The code works with simple examples.  I have however found a couple of
problems when the spreadsheets start to get more complex.  The first
error I have overcome.  It was populating the wrong comments if more
than one sheet was used.  To fix this I have changed the following
lines of code.

'Get cell address of each point
'xAddress = Range(xVals).Cells(Counter, 2).Address
xAddress = Left(xVals, InStr(xVals,
"!"))&Range(xVals).Cells(Counter,2).Address

The second error I can't seem to solve.  When there is no data for
sections of the series, it gets an error and bombs out.  Usually at
the line.

ser.Points(Counter).HasDataLabel = True 

Any ideas please let me know.  Also if my loops could be done more
eficently please feel free to let me know.

Cheers.
0
lowegreg (2)
6/22/2004 6:01:25 AM
Reply:

Similar Artilces:

Cell refering filename in formula bar
How do you refer filename1 to a cell in the formula bar? Example: ='\\Year 2004\September\[_filename1_.xls]sheet1'!$A$1 A | B | C 1 | | 2 | filename1 | 3 | | 4 | | ="\\Year 2004\September\["_B2_".xls]sheet1'!$A$1 will not work -- yee ve ----------------------------------------------------------------------- yee ven's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1479 View this thread: http://www.excel...

Adding hyperlinks with parameters
Hey everybody I have a batch file which needs to be run from an excel sheet with a parameter, like this: c:\1.bat myParameter But when i try to run the Hyperlink, the Excel shows an error message saying it can't open the specified file (probably because the is a space between the file and the parameter) is there any known way to run the link from the excel? On Mar 2, 12:45=A0pm, Pasha <pavel_v...@mailto.mod.gov.il> wrote: > Hey everybody > I have a batch file which needs to be run from an excel sheet with a > parameter, like this: > c:\1.bat myParameter > But when i ...

Adding Blank Rows after the last Detail of the Report
Hi All, I've used this code from Dwayne: Private Sub Report_Page() Dim intNumLines As Integer Dim intLineNumber As Integer Dim intTopMargin As Integer Dim ctl As Control Dim intLineHeight As Integer intNumLines = 12 intTopMargin = Me.Section(3).Height intLineHeight = Me.Section(0).Height For Each ctl In Me.Section(0).Controls For intLineNumber = 0 To intNumLines - 1 Me.Line (ctl.Left, intTopMargin + _ (intLineNumber * intLineHeight)) - _ Step(ctl.Width, intLineHeight), , B Next Next End Sub My report needs to print blank rows (at least...

VBA pick random cell
hi, i want to pick a random cell (containing text) in a given range. i used the "randbetween" function in excel, but i am now needing thi in visual basic. i found the following vba snipplet, but i don�t understand it, an can�t implement it in my code: PHP code ------------------- With Range("B1") .FormulaR1C1 = _ "=OFFSET(Sheet1!RC[-1],RANDBETWEEN(0,9),0)" ------------------- it would be great if someone could give me an example of picking random cell in the range lets say ("A1:B10") i would also like to know how to combine two ra...

chart axis title
Heeeeeelp I have MS excel 2000. Every time I plot a chart the y-axis title is incomplete (a few letters are missing off the end). It does not let m change the title-box size via the usual route (i.e. dragging one of th corners with the mouse). If I change the font size of the title, the bo also gets smaller and half of the title is still missing. The x-axis i fine, only the y-axis is causing problems. When I open the same file up on any other computer with the same Exce version it works fine, the problem only appears on my laptop which i only 2 months old. Is there some way of changing ...

Line & Double Stacked Charts
Good day. I am trying to get a Double stacked chart to show a line. I can get the line by creating a secondary Axis however the line isnt where I want it. It is at the top of the tallest bar. Is there any way to get the line down to a value I want it at. Basically I am trying to create a capacity chart with two products running on one machine by month. I need the line to be at a value that is straight accross being the maximum machine capacity. Any help would be greatly appreciated. Thanks "K" wrote: > Good day. I am trying to get a Double stacked chart to show a line...

outlook vcard, ad integration user properties
my boss is trying to get hix fax# in his vcard. he is using his address from the global address list I have modified his profile in active directory users and computers: I go into AD users and computers, double click on his user, go to the telephones tab, and enter his fax #. but when I did this his fax # is still not being pulled up in his outlook vcard. Does anyone know where outlook is trying to get this field from / how i can get this field into his vcard? thx ...

Simple? pie chart
Hi I have data like this customer food service ---------------------------- john excellent good mary excellent excellent david fair fair diane good good jim poor fair I want to create one pie chart for food (and one for service) that hows what % of customer rated the food (service, resp.) as excellent/good/fair/poor. Seems pretty simple, but naturally it's not. Set up a table with the ratings in the firs column, and the categories across the top: Food Service poor fair good excellent In the first cell under food (G2 in thi...

Formatting Cells/Data
Hi, I hope you are doing well. I have a file I downloaded from our AS/400 (OS400 operating system). I open the file as a text file and go thru the wizard for converting the file to excel format. One of the columns/fields is numeric with some neg and pos numbers and some blank cell contents. During the wizard conversion the field is categorized as DOUBLE with no option to change the field. When I finish the wizard I save the file as an Excel workbook. Then I use the autosum option to calculate the total of the field/column; however, it only picks up on the positive #'s. Hence the t...

ADDING A NUMBER
how do i add a number to a range of cells? I need to add 11.27 to a number of different cells each with a different number in them Put 11.27 in an empty cell, format it the same way as the numbers you want to add to, copy it, then select the numbers you want to add to and do edit>paste special and select add. -- Regards, Peo Sjoblom "Helpme" <Helpme@discussions.microsoft.com> wrote in message news:6D51344A-78E6-4377-B292-FC6C16FF6BA2@microsoft.com... > how do i add a number to a range of cells? I need to add 11.27 to a > number > of different cells e...

How do you find and replace text in autoshapes or comments
Excel 2000 find and replace text in multiple autoshapes or comments, not in cells ...

Count cells that Contain text
Is there a way in excel to count the number of cells in a colum tha contain a specific piece of text, e.g. "ACT" I know that I can use the countif or sumproduct functions to coun cells which *only* contain "ACT" but I need to count the number o cells in a column which countain ACT but may also contain other text a well. You can manually do it using autofilters but I need to count it using formula. Any help would be greatly appreciated. Ta And -- Message posted from http://www.ExcelForum.com =COUNTIF(Range,"*ACT*") -- Regards, Peo Sjoblom (No private...

When adding attachments...
....in Outlook the following errors comes up: "Out of memory or system resources, please close some programs and try again" Quotas are fine. I have deinstalled/reinstalled Office, cleaned 'temp' areas, and many other tidbits. Any other ideas? Thanks. This might help as i had this problem with Outlook 98. Is the file you are trying to copy to attach nested in sub folders? if so try and copy the attachment to a root drive like c:\ Ignore previous email. wrong spellin if the attachment is nested in sub folders(this means you have to open different folders to get to ...

Area chart Disappears
Hi, i've a created graph with a combination of Line Chart & Area Chart. Everything is fine, but when I post it in my company's intranet server and somebody tries to open it, the Area Chart simply disappears and they only see the Line chart in that graph!! I tried to open from several different computers but still the same. As I mentioned, if I open it from my computer it works fine. HELP ! If you are using a PDF program to post the charts, check to make sur your title bars aren't even close to the chart area. There has to b space between them. Hope this helps -- T...

click on a cell to expand with more information
I am making a phone contact record for work. How can I make a cell (with a customers name in it) expose more details or information about that customer, when hovered over with the pointer? I also need to know how to enter the information to be viewed. 2nd question - How do I create a line between multiple entries for the same customer and the next customer? example: John Doe 05/05/05 123-456-7891 9:00 left message John Doe 05/08/05 123-456-7891 9:30 left message John Doe 05/08/05 123-456-7891 10:00 returned call _____________...

adding new records
I am totally new to CRM, so I hope this is really easy question: This concerns permissions.. I have a "sales" group, and with one of those people i need to be able to let them add new records on behalf of other "sales" people. Is there like a standard permission setting for it? (obviously every "sales" person can add new records if they select them selfs as the owner) thanks, Michal. Hi, By default the person who creates the record will be the owner. After record creation the person could reassign the record (manually) to another user. If all rec...

How-to hide comment field on Invoices
For one of our customers, we needed a way of classifying items which are Urgent in need to make sure our warehouse ships them out as soon as they are received. The only way field that would work is the 'Comment ID' field which can be found in the 'Sales Item Detail Entry' window. I then modified the related smartlist report to use this field and life was good.. until we printed invoices. On the Invoice, for every 'Urgent' item, a blank line appears after it. With more than one 'urgent' item on the same Invoice, it makes for an odd/unprofessional looking Invoice...

Picture Disappears When Added To Contact In Outlook 2003
Can someone help please. When I try to attach a picture to a contact in outlook 2003 immediately I double click the picture to be attached it disappears out of the outlook contact along with the placement holder in the form. Only when I right click the mouse and go remove picture do I get the placement holder back. I have looked at all the help menus but they offer no clues. Thanks TS ...

Adding ActiveX to dialog with wrapper
When I add an ActiveX object to a dialog using the dialog editor - right click - insert activeX object, the help on the resulting activex selection tool states that a wrapper will not be added by using this method. If you need a wrapper, it suggests using the class view. This is using Visual Studio 2005. I'm having some problems with this on an existing project. To make sure I understand the process, I created a new MFC project, added a dialog, created a class for that dialog and added a Flexgrid object using the right click method in the dialog. I then added a variable for the flexgrid...

merging cells #3
Hi, I got an Excel file from a friend where I combined two columns, area code and phone number. Everything works in Excel, except that the rows and column lines are grey and not black. Outlook does not see the new column. What could be the problem? Thanks AJS Solved it. "AJS" <newsgroup@sorga.com> wrote in message news:%232OPgj%23dJHA.4900@TK2MSFTNGP06.phx.gbl... | Hi, | I got an Excel file from a friend where I combined two columns, area code | and phone number. | Everything works in Excel, except that the rows and column lines are | grey and not black. | Outlook does n...

Adding alternate columns
I work on a schedule where I record ticket count and ticket sales for each show, listed chronologically. Column A = week ending date Column B = # Tickets sold for April 5 show Column C = Ticket Revenue for April 5 show Column D = # Tickets sold for April 9 show Column E = Ticket Revenue for April 9 show Column F = # Tickets sold for April 12 show Column G = Ticket Revenue for April 12 show Column H = Total # Tickets sold for all shows Column I = Total Ticket Revenue for all shows In the Totals columns, the Total Tickets formula is "+B4+D4+F4", and the Total Revenue f...

Conditional Colors for Charts #2
Hello, I have on a sheet with several graphs and I would like to execute the procedure below automatically. In advance thank you for the assistance Yves Sub ColorColumns() Dim vntValues As Variant Dim intSeries As Integer Dim intPoint As Integer With ActiveChart For intSeries = 1 To .SeriesCollection.Count With .SeriesCollection(intSeries) vntValues = .Values For intPoint = 1 To .Points.Count If vntValues(intPoint) < 60 Then ..Points(intPoint).Interior.Color = vbRed ElseIf vntValues(intPoint) >= 60 And vntValues(intPoint) < 80 Then ..Points(intPoint).Interior.Color = vbYellow E...

Adding fields from a different query
I have a form built based on a main query. How do I add more fields on that form that come from a different query? Anne A couple possibilities... Change your first query to include the extra fields. Use your second query to "feed" a form, then embed that form as a subform on your main form. Good luck! Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein does not constitute endorsement thereof. Any code or pseudoco...

delete first two words in a cell
hi, can someone tell me how i manage to delete the first two words in cell? eg. July 24: info prodid4775 gorass andreas -should become- info prodid4775 gorass andreas or is it possible to extract every word beginning at the third one? i was playing around with some code i found at excel tip: =IF(ISERR(FIND(" ",A1)),A1,LEFT(A1,FIND(" ",A1)-1)) it is supposed to extract the first word of A1. for some reason i only get an error message. i am working with excel 2002. hope someone can help me out greetz f -- flashing fran ------------------------------------------------...

Adding more than three Conditions to 'Conditional Formatting'
Can i add more than three conditions to the conditional formatting presets using code? Regards [Riz] -- Rizitsu ------------------------------------------------------------------------ Rizitsu's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=15840 View this thread: http://www.excelforum.com/showthread.php?threadid=320382 Riz, as you have found out, only 3 conditions with conditional formatting. But yes you can use some code to get more than 3, try this it will change the cell color in column A when you put in one ,two, three, or four, right click on the she...