<?xml version="1.0" encoding="utf-8"?> 
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom">

    <channel>
    
    <title>Excel Blog</title>
    <link>http://www.cellmatrix.net/index.php/site/index/</link>
    <description>Formulas, Charts, and Models Created with Microsoft Excel.</description>
    <dc:language>en</dc:language>
    <dc:creator>jfm</dc:creator>
    <dc:rights>Copyright 2010</dc:rights>
    <dc:date>2010-02-23T12:30:55+00:00</dc:date>
    <admin:generatorAgent rdf:resource="http://expressionengine.com/" />
    <atom:link href="http://www.cellmatrix.net/index.php/site/rss_2.0/" rel="self" type="application/rss+xml" />
    

    <item>
      <title>Add an ActiveX SpinButton Control to a Spreadsheet</title>
      <link>http://www.cellmatrix.net/index.php/site/add_an_activex_spinbutton_control_to_a_spreadsheet/</link>
      <guid>http://www.cellmatrix.net/index.php/site/add_an_activex_spinbutton_control_to_a_spreadsheet/</guid>
      <description>
            <![CDATA[<p>One of my favorite tools for controlling the input to a single cell within an interactive spreadsheet model is an ActiveX SpinButton.  When added to a spreadsheet, the SpinButton can allow the user to move quickly through multiple scenarios within a predefined range of values.</p>  

<p>In Excel 2007, you can add an ActiveX SpinButton to a spreadsheet by first selecting the Developer tab.  Then select Insert -> ActiveX Controls -> Spin Button.</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2010220101.bmp" style="border: 0;" alt="image" width="633" height="379" />
</div>

<p>In Design mode, you can link a cell as well as adjust the minimum and maximum values for the SpinButton.  To do so, click on the SpinButton when in design mode.  Then right-click on your mouse to access the properies for that SpinButton.</p>

<p>Rather than manually entering the minimum, maximum, and linked cell properties, my personal preference is to use a few simple VBA statements.  For example, assuming the SpinButton is named "SpinButton1", to add a maximum value = 30, a minimum value = 20, and a linked cell = C4, and an incremental value = 1, add the following code to the sheet module for the sheet containing the ActiveX SpinButton.</p> 

<pre>
Private Sub SpinButton1_SpinDown()
    With Range("C4")
        .Value = WorksheetFunction.Max(20, .Value - 1)
    End With
End Sub

Private Sub SpinButton1_SpinUp()
    With Range("C4")
        .Value = WorksheetFunction.Min(30, .Value + 1)
    End With
End Sub
</pre>

<p>The cell entry for the SpinButton combined with the SpinButton Control might be set up on the spreadsheet to look like this:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2010220102.bmp" style="border: 0;" alt="image" width="322" height="125" />
</div>

<p>To allow the SpinButton to accept changes in percent, slightly modify the code above.  For example, to add a maximum value = .50, a minimum value = .30, and a linked cell = C4, and an incremental value = .01, add the following code to the sheet module for the sheet containing the ActiveX SpinButton.</p>

<pre>
Private Sub SpinButton1_SpinDown()
    With Range("C4")
        .Value = WorksheetFunction.Max(0.3, .Value - 0.01)
    End With
End Sub

Private Sub SpinButton1_SpinUp()
    With Range("C4")
        .Value = WorksheetFunction.Min(0.5, .Value + 0.01)
    End With
End Sub
</pre>

<p>After changing the cell entry number format to percent, for the SpinButton combined with the SpinButton Control might be set up on the spreadsheet to look like this:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2010220103.bmp" style="border: 0;" alt="image" width="322" height="125" />
</div>

<p>Although you must be in design mode to modify the size and position of the SpinButton and /or modify its properties, you must exit the design mode in order for the SpinButton to be operable.</p>  

<p>Note: the examples above are based on code and techniques that can be found at the following:</p>
<ul>
<li>From java2s.com:  <a href="http://www.java2s.com/Code/VBA-Excel-Access-Word/Forms/Spinupeventprocedureforspinbutton.htm" title="SpinUp Events">SpinUp Events</a></li>
<li>From java2s.com:  <a href="http://www.java2s.com/Code/VBA-Excel-Access-Word/Forms/ThespinbuttoncontrolusestheSpinDownandSpinUpeventstodecreaseandincreasethevalueincellB4.htm" title="SpinDown Events">SpinDown Events</a></li>
<li>From Microsoft:  <a href="http://office.microsoft.com/en-us/excel/HP102366821033.aspx" title="Add a Scroll Bar or Spin Button to a Worksheet">Add a Scroll Bar or Spin Button to a Worksheet</a></li>
<li><a href="http://spreadsheetpage.com/index.php/book/excel_2007_power_programming_with_vba/" title="Excel 2007 Power Programming with VBA">Excel 2007 Power Programming with VBA</a> by John Walkenbach - Chapter 13 - Pages 440 - 442.</li>
<li>Excel 2000 VBA by John Green - Chapter 10 - page 175.</li>
</ul>

<br/>
            <hr /> 
            <p>Posted on: February 23, 2010  |
            Filed Under: <a href="http://www.cellmatrix.net/index.php/site/category/VBA/">VBA</a> | 
            <a href="http://www.cellmatrix.net/index.php/site/comments/add_an_activex_spinbutton_control_to_a_spreadsheet/">Comments:</a> (2)</p> 
            ]]>
      </description>
      <dc:subject>VBA</dc:subject>
      <dc:date>2010-02-23T12:30:55+00:00</dc:date>
    </item>

    <item>
      <title>Excel 2010 Chart Improvements &#45; Migrating Excel 4 Macros to VBA</title>
      <link>http://www.cellmatrix.net/index.php/site/excel_2010_chart_improvements_-_migrating_excel_4_macros_to_vba/</link>
      <guid>http://www.cellmatrix.net/index.php/site/excel_2010_chart_improvements_-_migrating_excel_4_macros_to_vba/</guid>
      <description>
            <![CDATA[<p>From the <a href="http://blogs.msdn.com/excel/archive/2010/02/16/migrating-excel-4-macros-to-vba.aspx" title="Microsoft Excel Product Team Blog">Microsoft Excel Product Team Blog</a> . . .</p> 

<p><i>There are a number of properties for chart elements that were previously only accessible through the Excel 4 Macro Language. We have added additional properties to VBA for these items.</i></p>

<p><b>Formula Properties</b> - <i>New properties replace the GET.FORMULA() XLM command, providing formula support for missing chart elements. New Formula properties (Formula, FormulaR1C1, FormulaLocal, FormulaR1C1Local) have been added for AxisTitle, ChartTitle, DisplayUnitLabel, and DataLabel objects.</i></p>

<p><b>Series/Point Name</b> - <i>The chart object model currently doesn’t provide a way to determine the series name that is given to a series when it is created. This information is available when hovering over a data point with the mouse, or using the SELECTION() function in XLM. The XLM command returns a point name in the format “SmPn” where m is the series number assigned when the chart is created and n is the point number. For example, when selecting a point on a chart, SELECTION() returns "S1P3". A new Point.Name property has been added that Returns a point name in the format “SmPn” where m is the series number assigned when the chart is created and n is the point number.</i></p> 

<p><b>Position Properties</b> - <i>The XLM Function GET.CHART.ITEM returns the X,Y coordinates of the corners or mid-points of any chart item. This function had been necessary for some chart elements that did not have positional (.Left, .Top, .Width, and .Height) properties. In Excel 2010 we added .Left, .Top, .Width, and .Height properties for any chart elements that did not have them. This included AxisTitle, ChartTitle, DisplayUnitLabel, Point, and DataLabel objects. Additionally we added a Point.PieSliceLocation Method that returns coordinates of multiple points on Pie Slices.</i></p>

<br/>

            <hr /> 
            <p>Posted on: February 19, 2010  |
            Filed Under: <a href="http://www.cellmatrix.net/index.php/site/category/Charts/">Charts</a> | 
            <a href="http://www.cellmatrix.net/index.php/site/comments/excel_2010_chart_improvements_-_migrating_excel_4_macros_to_vba/">Comments:</a> (0)</p> 
            ]]>
      </description>
      <dc:subject>Charts</dc:subject>
      <dc:date>2010-02-19T11:56:12+00:00</dc:date>
    </item>

    <item>
      <title>RefEdit Entries</title>
      <link>http://www.cellmatrix.net/index.php/site/refedit_entries/</link>
      <guid>http://www.cellmatrix.net/index.php/site/refedit_entries/</guid>
      <description>
            <![CDATA[<p>Recently I've been working on creating a ribbon tab for Excel 2007 that interfaces with and controls several of the add-ins that I use for work.  The  
<a href="http://www.cellmatrix.net/index.php/excel/comments/goal_seek_tool/" title="Goal Seek Tool">Goal Seek Tool</a> is one of those add-ins.  I created this tool to allow the  entry of a single-cell range or value when performing the goal-seek function.</p>

<p>In November 2008 I wrote a short post about my Goal Seek tool.  In my first version of that tool, I used a RefEdit control to enter a range and a textbox to enter a value.  In a comment to that post, <a href="http://peltiertech.com/" title="Jon Peltier">Jon Peltier</a> noted that the textbox could be eliminated and the RefEdit control could be programmed to accept either a range or text entry.</p>

<p>After a lot of time searching the internet, I finally found an example of how this functionality could work on the <a href="http://www.tushar-mehta.com/" title="TM Consulting ">TM Consulting</a> site.  It looks like this:</p>

<p>When wanting to enter a range with RefEdit and assuming the RefEdit control is named "RefEdit1", use</p>

<pre>
Range(RefEdit1) 
</pre>  

<p>When wanting to enter a value with RefEdit, use</p>

<pre>
Range(RefEdit1).value 
</pre>  

<p>When wanting to validate the entries made into RefEdit, you can use examples like:</p>

<p>To validate that a range contains a formula, use</p>

<pre>
HasFormula(Range(RefEdit1)) 
</pre>  

<p>To validate that a range contains a number, use</p>

<pre>
IsNumeric(RefEdit1)
</pre>  

<br/>


            <hr /> 
            <p>Posted on: February 16, 2010  |
            Filed Under: <a href="http://www.cellmatrix.net/index.php/site/category/VBA/">VBA</a> | 
            <a href="http://www.cellmatrix.net/index.php/site/comments/refedit_entries/">Comments:</a> (0)</p> 
            ]]>
      </description>
      <dc:subject>VBA</dc:subject>
      <dc:date>2010-02-16T11:47:32+00:00</dc:date>
    </item>

    <item>
      <title>VBA Fireworks Model from AJP Excel Information</title>
      <link>http://www.cellmatrix.net/index.php/site/vba_fireworks_model_from_ajp_excel_information/</link>
      <guid>http://www.cellmatrix.net/index.php/site/vba_fireworks_model_from_ajp_excel_information/</guid>
      <description>
            <![CDATA[<p>Recently I had the opportunity to build Andy Pope's <a href="http://www.andypope.info/fun/fireworks.htm" title="fireworks display">fireworks display</a> into a line chart that I produce each month.  Fireworks were requested because 2009 was the best year on record for a particular business unit at work.  When I presented the operating results the animation was a big hit.</p>  

<p>Once you download the file you'll find that Andy's display utilizes an XY Scatter chart and VBA code with trigonometry functions to produce the fireworks.  Because the code is unprotected you can easily load the modules into your own project and then customize the code as you wish.  Even if you don't have an interest in using the display, the file is worth downloading just to study how the model was developed.  Thanks Andy for making this available.</p>       
            <hr /> 
            <p>Posted on: January 28, 2010  |
            Filed Under: <a href="http://www.cellmatrix.net/index.php/site/category/VBA/">VBA</a> | 
            <a href="http://www.cellmatrix.net/index.php/site/comments/vba_fireworks_model_from_ajp_excel_information/">Comments:</a> (0)</p> 
            ]]>
      </description>
      <dc:subject>VBA</dc:subject>
      <dc:date>2010-01-28T11:33:09+00:00</dc:date>
    </item>

    <item>
      <title>Turn off Automatic Hyperlinks</title>
      <link>http://www.cellmatrix.net/index.php/site/turn_off_automatic_hyperlinks/</link>
      <guid>http://www.cellmatrix.net/index.php/site/turn_off_automatic_hyperlinks/</guid>
      <description>
            <![CDATA[<p>Does it annoy you when Excel automatically turns an email or web address into a hyperlink when you want it entered as text?  In Excel 2007 you can prevent this from happening by clicking on the Office button and going to Excel Options -> Proofing -> Deselect the option titled "Ignore Internet and file addresses".</p>

<p>The <a href="http://spreadsheetpage.com/" title="The Spreadsheet Page">The Spreadsheet Page</a> has a tip titled <a href="http://spreadsheetpage.com/index.php/tip/removing_or_avoiding_automatic_hyperlinks/" title="Removing or Avoiding Automatic Hyperlinks">Removing or Avoiding Automatic Hyperlinks</a> that covers this very topic.  The tip provides the following macro which will allow you to instantly turn all of your hyperlinks into text.  The macro really helped me as I had a sheet with over 100 links to zap.</p>

<pre>
Sub ZapHyperlinks() 
    Cells.Hyperlinks.Delete
End Sub
</pre>

<p>As I'm just making the switch from Excel 2003 to 2007 it made me think . . . what features do Excel users automatically turn on or off when moving to a different version?  Understanding that everyone has their own preferences, I'd like to hear about those features that are a "must have" or that you immediately shut off.</p>  

<br/>


            <hr /> 
            <p>Posted on: January 17, 2010  |
            Filed Under: <a href="http://www.cellmatrix.net/index.php/site/category/General/">General</a> | 
            <a href="http://www.cellmatrix.net/index.php/site/comments/turn_off_automatic_hyperlinks/">Comments:</a> (2)</p> 
            ]]>
      </description>
      <dc:subject>General</dc:subject>
      <dc:date>2010-01-17T14:44:26+00:00</dc:date>
    </item>

    <item>
      <title>VBA Array to Change Line Chart Colors</title>
      <link>http://www.cellmatrix.net/index.php/site/vba_array_to_change_line_chart_colors/</link>
      <guid>http://www.cellmatrix.net/index.php/site/vba_array_to_change_line_chart_colors/</guid>
      <description>
            <![CDATA[<p>Part of my responsibilities at work is building the end-of-month financial packet that is presented to management.  That packet includes a variety of line charts that show trends in financial and statistical metrics.  Many of the graphs start with a base year and require adding an additional line as the year turns over.  For example, in 2009 and given a base year of 2006 each line chart would have five lines (2006, 2007, 2008, 2009 plan, and 2009 actual).  Now that the year has turned over, each graph will have six lines (2006, 2007, 2008, 2009, 2010 plan, and 2010 actual).</p>

<p>This may or may not be the most efficient process, but I prefer to keep the line series order as follows:</p>

<ul>
<li>Series 1 = Current Year (2010) -> line color = red</li>
<li>Series 2 = Current Year Plan (2010) -> line color = blue</li>
<li>Series 3 = Prior Year (2009) -> line color = green</li>
<li>Series 4 = Prior Year - 1 (2008) -> line color = silver</li>
<li>Series 5 = Prior Year - 2 (2007) -> line color = silver</li>
<li>Series 6 = Prior Year - 3 (2006) -> line color = silver</li>
</ul>  

<p>This logic can present a problem in that as an additional series is added, the series order needs to be renumbered and the line colors have to be redone.  To make the process easier, we use the following macro to change the series colors.  It uses an array to store the color index numbers for each series.</p>

<pre>
Sub Color_Series()

    Dim arrColors(1 To 6) As Integer
    
    Dim Cht As ChartObject
    
    Dim i As Integer
     
    arrColors(1) = 3    'Series 1 - Red = Current Year (2010)
    arrColors(2) = 5    'Series 2 - Blue = Current Year Plan (2010)
    arrColors(3) = 10  'Series 3 - Green = Prior Year (2009)
    arrColors(4) = 16  'Series 4 - Silver = Prior Year (2008)
    arrColors(5) = 15  'Series 5 - Silver = Prior Year (2007)
    arrColors(6) = 14  'Series 6 - Silver = Prior Year (2006)
    
    Set Cht = Worksheets("Sheet1").ChartObjects("Chart01")
    
    For i = LBound(arrColors) To UBound(arrColors)
    
        Cht.Chart.SeriesCollection(i).Border.ColorIndex = arrColors(i)
        
    Next i
    
End Sub
</pre> 

<p>Rather than looping through an array, you could just as easily refer to each of the series individually.  To do so, the code would look like this:</p>

<pre>
Sub Color_Series()

    Dim Cht As ChartObject
    
    'Series 1 - ColorIndex = 3 = Red = Current Year (2010)
    'Series 2 - ColorIndex = 5 = Blue = Current Year Plan (2010)
    'Series 3 - ColorIndex = 10 = Green = Prior Year (2009)
    'Series 4 - ColorIndex = 16 = Silver = Prior Year (2008)
    'Series 5 - ColorIndex = 15 = Prior Year (2007)
    'Series 6 - ColorIndex = 14 = Silver = Prior Year (2006)
    
    Set Cht = Worksheets("Sheet1").ChartObjects("Chart01")
    
    Cht.Chart.SeriesCollection(1).Border.ColorIndex = 3
    Cht.Chart.SeriesCollection(2).Border.ColorIndex = 5
    Cht.Chart.SeriesCollection(3).Border.ColorIndex = 10
    Cht.Chart.SeriesCollection(4).Border.ColorIndex = 16
    Cht.Chart.SeriesCollection(5).Border.ColorIndex = 15
    Cht.Chart.SeriesCollection(6).Border.ColorIndex = 16
        
End Sub
</pre> 

<br/>


            <hr /> 
            <p>Posted on: January 11, 2010  |
            Filed Under: <a href="http://www.cellmatrix.net/index.php/site/category/Charts/">Charts</a> | 
            <a href="http://www.cellmatrix.net/index.php/site/comments/vba_array_to_change_line_chart_colors/">Comments:</a> (0)</p> 
            ]]>
      </description>
      <dc:subject>Charts</dc:subject>
      <dc:date>2010-01-11T11:00:34+00:00</dc:date>
    </item>

    <item>
      <title>VBA Function to Screen for Certain Charts</title>
      <link>http://www.cellmatrix.net/index.php/site/vba_function_to_screen_for_certain_charts/</link>
      <guid>http://www.cellmatrix.net/index.php/site/vba_function_to_screen_for_certain_charts/</guid>
      <description>
            <![CDATA[<p>Until late last year I've primarily worked with Excel 2003 because that's what we use at work.  However, that changed over the holidays because my home computer crashed and the new one came with Excel 2007.  I was trying to wait until Excel 2010 was available before buying a new computer but the old machine just couldn't make it that long.</p>

<p>It seems like most of what I've read regarding the Excel 2007 ribbon has been negative.  However, after using Excel 2007 for a couple of weeks my initial impressions are that I like it.  Although the ribbon can't be modified as easy as the toolbars were in previous versions, having the ability to create your own ribbon tabs makes up for that problem for me.  And having the ability to customize the quick access toolbar makes up for inefficiencies in the placement of the ribbon commends.</p>

<p>Now that I've made the move to 2007, I need to rebuild several add-ins that I've created to interface with the ribbon.  One of the add-ins that I've created is for working with embedded charts only.  Built into that add-in is a function written by <a href="http://spreadsheetpage.com/" title="John Walkenbach">John Walkenbach</a> that alerts the user if he or she failed to select a chart.  After screening for a chart selection, I've added a second chart-screening function that utilizes a case statement to alert the user if an "improper" chart type is selected.  In the example, an improper chart is by my definition only.  That second chart-screening function follows:</p>

<p>First, declare an optional public variable containing the name of the application (add-in).</p>

<pre>
Option Explicit
Public Const APPNAME As String = "Position Chart Labels"
</pre>

<p>Next, provide the code that triggers the user form.  "ValidContext" references the chart screening function below.</p>

<pre>
Sub MoveChartLabels()
    If ValidContext(True) Then frmMoveLabels.Show
End Sub
</pre>

<p>Finally, provide the chart screening function.  If the chart type appears as a line in the code below the function considers the chart to be valid.  If not, the function kicks out an error message.  The function works with combination charts because it evaluates each individual chart series for the accepted chart type.</p>

<pre>
Private Function ValidContext(ChtType) As Boolean
   
    Dim Sr As Series
    Dim Srs As SeriesCollection
    
    Const MsgChtType As String = "Invalid chart type."
        
    Set Srs = ActiveChart.SeriesCollection
    
    For Each Sr In Srs
     
        Select Case Sr.ChartType
            
            'Accepted Line Charts
            Case xlLine: ValidContext = True
            Case xlLineStacked: ValidContext = True
            Case xlLineStacked100: ValidContext = True
            Case xlLineMarkers: ValidContext = True
            Case xlLineMarkersStacked: ValidContext = True
            Case xlLineMarkersStacked100: ValidContext = True
            
            'Accepted Column Charts
            Case xlColumnClustered: ValidContext = True
            Case xlColumnStacked: ValidContext = True
            Case xlColumnStacked100: ValidContext = True
        
            'Accepted Bar Charts
            Case xlBarClustered: ValidContext = True
            Case xlBarStacked: ValidContext = True
            Case xlBarStacked100: ValidContext = True
                    
            'Accepted Area Charts
            Case xlArea: ValidContext = True
            Case xlAreaStacked: ValidContext = True
            Case xlAreaStacked100: ValidContext = True
            
            'Accepted XY Scatter Charts
            Case xlXYScatter: ValidContext = True
            Case xlXYScatterSmooth: ValidContext = True
            Case xlXYScatterSmoothNoMarkers: ValidContext = True
            Case xlXYScatterLines: ValidContext = True
            Case xlXYScatterLinesNoMarkers: ValidContext = True
    
            'Accepted Pie Charts
            Case xlPie: ValidContext = True
            Case xlPieExploded: ValidContext = True
            Case xlPieOfPie: ValidContext = True
            Case xlBarOfPie: ValidContext = True
            
            Case Else
                ValidContext = False
                MsgBox MsgChtType, vbCritical, APPNAME
                Exit Function
        
        End Select

    Next Sr
    
End Function
</pre>

<br/>
            <hr /> 
            <p>Posted on: January 08, 2010  |
            Filed Under: <a href="http://www.cellmatrix.net/index.php/site/category/Charts/">Charts</a> | 
            <a href="http://www.cellmatrix.net/index.php/site/comments/vba_function_to_screen_for_certain_charts/">Comments:</a> (0)</p> 
            ]]>
      </description>
      <dc:subject>Charts</dc:subject>
      <dc:date>2010-01-08T11:10:41+00:00</dc:date>
    </item>

    <item>
      <title>VBA for Adding and Deleting Data Labels</title>
      <link>http://www.cellmatrix.net/index.php/site/vba_for_adding_and_deleting_data_labels/</link>
      <guid>http://www.cellmatrix.net/index.php/site/vba_for_adding_and_deleting_data_labels/</guid>
      <description>
            <![CDATA[<p>I'm currently working on a project where I have multiple embedded line charts in a workbook.  Each line chart contains any number of multiple series.  Each series contains 12 points representing each month of the year.  For each chart I need to show the data points for the current month only.</p>

<p>Although the combination Line - XY Scatter chart works, I want to use VBA to add and delete the data labels in each chart in an effort to minimize the number of chart series that the owner of the workbook needs to maintain.  Below are some simple macros for adding and deleting data labels that I've used for reference and / or utilized in my project.  Each example works for the active chart only (an active single embedded chart).</p> 

<p>To delete a label from a single series:</p>

<pre>
Sub Delete_Labels_From_A_Single_Series()
    For Each X In ActiveChart.SeriesCollection(1).Points
        X.DataLabel.Delete
    Next X
End Sub
</pre>

<p>A second method for deleting a label from a single series:</p>

<pre>
Sub Delete_Labels_From_A_Single_Series()
    
    Dim Cht As Chart
    Dim Srs As Series
    
    Set Cht = ActiveChart
    Set Srs = Cht.SeriesCollection(1)
    
        With Srs
            If .HasDataLabels Then .DataLabels.Delete
        End With

End Sub
</pre>

<p>To add data labels to multiple series at one time:</p>

<pre>
Sub Add_Data_Labels_To_All_Series()
    
    Dim Cht As Chart
    
    Set Cht = ActiveChart
    
    For Each Sr In Cht.SeriesCollection
        Sr.ApplyDataLabels
        Sr.DataLabels.ShowValue = True
        Sr.DataLabels.Position = xlLabelPositionAbove
    Next Sr

End Sub
</pre>

<p>To delete data labels from multiple series at one time:</p>

<pre>
Sub Delete_Data_Labels_From_All_Series()
    
    Dim Cht As Chart
    
    Set Cht = ActiveChart
    
    For Each Sr In Cht.SeriesCollection
        If Sr.HasDataLabels Then Sr.DataLabels.Delete
    Next Sr

End Sub
</pre>

<br/>







            <hr /> 
            <p>Posted on: December 22, 2009  |
            Filed Under: <a href="http://www.cellmatrix.net/index.php/site/category/Charts/">Charts</a> | 
            <a href="http://www.cellmatrix.net/index.php/site/comments/vba_for_adding_and_deleting_data_labels/">Comments:</a> (2)</p> 
            ]]>
      </description>
      <dc:subject>Charts</dc:subject>
      <dc:date>2009-12-22T09:03:45+00:00</dc:date>
    </item>

    <item>
      <title>Removing Spaces from File Names</title>
      <link>http://www.cellmatrix.net/index.php/site/removing_spaces_from_file_names/</link>
      <guid>http://www.cellmatrix.net/index.php/site/removing_spaces_from_file_names/</guid>
      <description>
            <![CDATA[<p>For a number of reasons I prefer to never use spaces in file names.  Recently Dick Kuslieka at the <a href="http://www.dailydoseofexcel.com/" title="Daily Dose of Excel">Daily Dose of Excel</a> posted an interesting VBA technique for <a href="http://www.dailydoseofexcel.com/archives/2009/11/12/removing-spaces-from-file-names/" title="removing spaces from file names">removing spaces from file names</a>.  John Walkenbach commented with a revision that will allow the same functionality using Excel 2007 and Rick Rothstein commented with another alternative.   These snippets are great additions to my VBA toolbox.</p>

<p>Dick's Kuslieka's original post:</p>

<pre>
Sub RemoveSpaces()
    
    Dim fso As FileSystemObject
    Dim fsoFile As File
    
    Set fso = New FileSystemObject
    
    For Each fsoFile In fso.GetFolder("C:\Tester").Files
        If InStr(1, fsoFile.Name, " ")> 0 Then
            fsoFile.Name = Replace(fsoFile.Name, " ", "_")
        End If
    Next fsoFile
    
End Sub
</pre>

<p>John Walkenbach's version for Excel 2007:</p>

<pre>
Sub RemoveSpaces()
    Const Folder As String = "C:\Tester\"
    Dim FileName As String, NewName As String
    FileName = Dir(Folder)
    Do While FileName  ""
        If InStr(1, FileName, " ")&gt; 0 Then
            NewName = Replace(FileName, " ", "_")
            Name Folder &amp; FileName As Folder &amp; NewName
        End If
        FileName = Dir
    Loop
End Sub
</pre>

<p>and Rick Rothstein commented with another version:</p>

<pre>
Sub RemoveSpaces()
  Dim Path As String, FileName As String
  Path = "C:\Tester\"  'Note the trailing backslash
  FileName = Dir(Path &amp; "*.*")
  Do While FileName  ""
    Name Path &amp; FileName As Path &amp; Replace(FileName, " ", "_")
    FileName = Dir
  Loop
End Sub
</pre>

<br/>


            <hr /> 
            <p>Posted on: November 19, 2009  |
            Filed Under: <a href="http://www.cellmatrix.net/index.php/site/category/VBA/">VBA</a> | 
            <a href="http://www.cellmatrix.net/index.php/site/comments/removing_spaces_from_file_names/">Comments:</a> (1)</p> 
            ]]>
      </description>
      <dc:subject>VBA</dc:subject>
      <dc:date>2009-11-19T10:25:12+00:00</dc:date>
    </item>

    <item>
      <title>Arrays to Calculate Consistent Increases in Rate Spreads</title>
      <link>http://www.cellmatrix.net/index.php/site/arrays_to_calculate_consistent_increases_in_rate_spreads/</link>
      <guid>http://www.cellmatrix.net/index.php/site/arrays_to_calculate_consistent_increases_in_rate_spreads/</guid>
      <description>
            <![CDATA[<p>Every year at work we go through a planning cycle for the following year.  During that time we build an annual and five year plan.  After those plans are approved and submitted, we revisit the annual plan and spread those results across each month of the year.  We then do a second submission of monthly results.</p>

<p>In going through that process, I've struggled to explain why the following calculation doesn't work . . .</p>

<p>In the example below we're given the total planned 2010 volume (in the yellow cell) that we need to spread.  The spread needs to be based on a consistent or even growth in the rate per work day.  We have history for volume in 2009 and workdays for 2009 and 2010 as well.  Below is a screenshot of what we know.</p>    
  
<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2009111401.gif" style="border: 0;" alt="image" width="494" height="155" />
</div>

<br/>

<p>On the surface this seems to be a simple algebra problem.  Knowing the total planned volume for 2010 and having 2009 as a base, the spread should be an easy calculation using the 6-month average volume per workday.</p>

<p>Using this logic, the calculation above now looks like this:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2009111402.gif" style="border: 0;" alt="image" width="494" height="227" />
</div>

<br/>

<p>In the range J12:J14, a rate per workday has been calculated for both years.  The change in the rate is applied to each month (range D12:I14).  Finally, the 2010 rate per workday (range D13:I13) is multipled by the workdays (range D9:I9) to get the volume for each month (range D5:I5).</p>

<p>All of this seems to make sense until you sum the range D5:I5.  Instead of getting a total volume of 85,265, the actual total volume is 83,345.  The total volume is overstated by 80 units, or 0.09%.</p> 

<p>To correct this error, instead of using the increase in the total volume per workday and then applying that increase to each month, an array formula can be used.  Referencing the screenshot below:</p>

<div class="ctr">
<img src="http://www.cellmatrix.net/images/uploads/2009111403.gif" style="border: 0;" alt="image" width="494" height="225" />
</div>

<br/>

<p>the following array formula is entered into the green shaded range D13:I13 (using CNTL - SHIFT - ENTER at the same time to enter the array formula):</p>

<pre>
{=J5 / SUM((D4:I4)/(D8:I8)*(D9:I9)) * (D12:I12)}
</pre>

<p>Now when you sum the range D5:I5 the total volume ties to 85,265.  However, the monthly change in the rate is now 4.77% which does not agree with the 6-month average change of 4.87%.  The difference is due to how the array formula evaluates each individual month and then totals the results.</p>
 
<br/>




 


  
            <hr /> 
            <p>Posted on: November 14, 2009  |
            Filed Under: <a href="http://www.cellmatrix.net/index.php/site/category/modeling/">Modeling</a> | 
            <a href="http://www.cellmatrix.net/index.php/site/comments/arrays_to_calculate_consistent_increases_in_rate_spreads/">Comments:</a> (0)</p> 
            ]]>
      </description>
      <dc:subject>Modeling</dc:subject>
      <dc:date>2009-11-14T14:47:05+00:00</dc:date>
    </item>

    </channel>
</rss>