Archive for the ‘VBA Advanced’ Category.

Adding RibbonX code to an Office OpenXML file using VBA

My previous post went a bit unnoticed, but I bet this one might interest some of the Office developers…
In that post, I showed how to access and modify existing parts of an Office OpenXML package. This opens up the path for us to add ribbon customisation code to an Office file. For this to happen, [...]

Editing elements in an Excel OpenXML file using VBA

Hi Everyone!
Today I finally found time to actually post a brand new article on my website.
Wouldn’t it be useful to be able to edit the contents of an Office 2007 OpenXML file from within VBA? Well, now you can, using the sample code and explanation in this article.
Enjoy!!
Regards,
Jan Karel Pieterse
www.jkp-ads.com

Lookup Second Occurrence

I need to do a VLOOKUP but find occurrences later than the first one. I've listed out all of my assemblies and all of their component parts like so:
Parent Child Quantity
To list the the children of a particular parent, I need a function that can find multiple occurrences of the parent. I considered [...]

On-the-fly data entry form

Hi all,
So after Dicks (nice to read) Alive and Well , let's do some Excel/VBA stuff again.
I intend to get a bit of discussion on this one, so bear with me.
I'm currently developing an Excel workbook for a customer. One of the interesting things with this project is that it consists of multiple data tables, [...]

Showing An Array On A Form; Autosizing ColumnWidths Of A ListBox

Hi all,
For a project I needed a quick way to display the content of an array to the user. I didn't want to use a worksheet, but opted for a userform. The data I wanted to show was contained in an array. The array contained something like:

Description
Before
After

Cell Errors
100
10

Corrupt Names
1000
0

Unused styles
232
0

So I figured I'd put a [...]

Rows and Columns

gullible.info sez:
An average Microsoft Excel spreadsheet document has 1,102 rows and 18.2 columns.
I say:

That's 470 rows and 25 columns. I had 408 sheets whose last cell was A1, i.e. blank. I attribute that to two things: I probably have quite a few workbooks that are just code; Most of the workbooks I get [...]

Terminating Dependent Classes

I have four objects that are all dependent on each other. They are CInvoice has many CInvoiceLines, CInvoiceLine has many CRoyaltyLines, CRoyaltyLine has many CRoyaltyAdjustments. In order to properly terminate all of these class modules, I need to remove any and all dependencies. If I don't, the classes will stay alive and [...]

VBA Code Documenting Tools: Project Analyzer and Visustin

Every VBA developer (which is anyone who knows how to get into the VBE I guess) develops his or her own programming habits: sparse commenting or elaborate commenting, naming convention (or no declaration at all), code indenting, preference for certain structures and methods over others. You name it. Many books have been written about this, [...]