Archive for 'VBA'
Label Each Series in a Chart
by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
In 9 Steps to Simpler Chart Formatting I suggested using data labels to identify each series rather than using a legend. I have a small VBA procedure that I use for this. It labels the last point of each series, and removes other labels. It also has an error trap that skips points that are [...]
Posted: Wednesday, October 15th, 2008 under VBA.
Comments: 13
Extract Chart Data
by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
This post presents a VBA procedure that extracts all data from a chart, and places it into a new worksheet. Why would you want to extract a chart’s data? Sometimes a chart gets its data from diverse sources, and you’d like to have the data in one place. You may receive a workbook that contains [...]
Posted: Tuesday, August 26th, 2008 under VBA.
Comments: 8
Calculating Easter
by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
The Calculating Easter post on John Walkenbach’s new Spreadsheet Page blog got me thinking. He presented a formula for calculating the date of Easter in a given year:
=DOLLAR((”4/”&A2)/7+MOD(19*MOD(A2,19)-7,30)*14%,)*7-6
Chip Pearson’s web site also has a couple formulas for calculating Easter:
=FLOOR(”5/”&DAY(MINUTE(A2/38)/2+56)&”/”&A2,7)-34
=FLOOR(DATE(A2,5,DAY(MINUTE(A2/38)/2+56)),7)-34
Chip also offers a UDF (VBA User Defined Function) which is valid through 2099, but breaks thereafter [...]
Posted: Friday, August 15th, 2008 under VBA.
Comments: 3
Chart Event Class Module to Highlight a Series
by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
In Chart Event to Highlight a Series, I showed how to use a chart legend plus chart events instead of a listbox, to select which series to highlight in a busy multi-series chart. That technique is useful, but it is not versatile: it is applicable only to a chart sheet that has the code in [...]
Posted: Thursday, August 14th, 2008 under VBA.
Comments: 6
Chart Event to Highlight a Series
by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
I’ve posted several times recently (for example, here, here, and here) showing examples that use a listbox to allow the user to highlight a series in a chart. Then I realized that the listbox requires an additional element which is not really integral to the chart. So I thought, why can’t I use a list [...]
Posted: Wednesday, August 13th, 2008 under VBA.
Comments: 12
Get Open or Save-As Filename
by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
GetOpenFilename and GetSaveAsFilename are useful dialogs to use within Excel VBA procedures when your procedure needs to know the filename of a file to open or save. I have encapsulated each into functions that add to their functionality, and make then simpler to use in my procedures.
Note that both GetXxxxFilename functions return file names. They [...]
Posted: Monday, June 30th, 2008 under VBA.
Comments: 1
File Name Functions
by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
Recently I posted several VBA procedures for exporting charts and other purposes. These make use of a number of procedures that I use when manipulating file names. I inadvertently left these out of the posts, so I am including them here.
The following shows what the functions return when passed a file name and path of [...]
Posted: Wednesday, June 11th, 2008 under VBA.
Comments: none
Enhanced Export Chart Procedure
by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
In Export Chart as Image File I described the VBA command to export a chart as an image file, and I presented a simple routine that exported the active chart.
I said that one day I would enhance the procedure to use GetSaveAsFileName, which allows the user to browse to any folder to save the image [...]
Posted: Monday, June 9th, 2008 under VBA.
Comments: 36
Installing an Excel Add-In
by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
A lot of Excel procedures are packaged in Add-Ins. An Add-In is basically a workbook containing some code, that has some other unique properties. The workbook is invisible. The workbook can be installed, which means it opens when Excel opens, so that its functionality is always available.
Installing an Add-In is really not complicated. If it [...]
Posted: Saturday, June 7th, 2008 under VBA.
Comments: 14
Export Chart as Image File
by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
Often people want to save their charts as an image file. Excel doesn’t offer this as a native feature in the UI, but you can export a chart using VBA:
ActiveChart.Export “C:\My Charts\SpecialChart.png”
This command allows you to export your chart in any of the bitmap formats that you have the appropriate export filters for. This varies [...]
Posted: Thursday, June 5th, 2008 under VBA.
Comments: 31














