Beyond Excel: VBA and Database Manipulation


September 24, 2014  8:06 AM

Excel Data Entry Protection Solution

Craig Hatmaker Craig Hatmaker Profile: Craig Hatmaker

Excel’s grid is perfect for some types of data entry, but in its startup mode, Excel is too wide open. For data entry we need to restrict entries to specific cells and specific values. Excel’s answer is Worksheet Protection and Data Validation. For me, Excel’s Worksheet Protection falls short.

Problem #1: Restricting Entries to Specific Cells.
Besides being cumbersome to setup, Excel’s Worksheet Protection prevents inserting or adding table rows. Excel’s grid is perfect for repeating rows of data which are required by Journal Entries, Time Sheets, Rate Tables and more. Preventing table row adds cripples Excel’s ability to work with these data sets.

Problem #2: Disabling Features
Excel’s Worksheet Protection also disables some of Excel’s wonderful features such as table sorting and filtering.

Problem #3: Data Validation and Conditional Formatting
Excel’s Worksheet Protection does nothing to prevent copy/paste operations from wiping out Data Validation and Conditional Formatting. Both of these features are absolutely critical to data entry. Good data entry apps MUST restrict entries to valid data and MUST convey errors which is normally done by text and highlighting cells in red or yellow.

Solution: Cursor Control Add-in
YouTube

This free add-in was designed to address these problems.

Easy Setup – Just format data entry cells with the INPUT style. INPUT, BAD, GOOD and NEUTRAL are all considered input styles. All other styles, including NORMAL are protected.

Table Rows – Cursor Control add’s rows to the bottom of tables when the user selects the last row. It also allows inserting table rows.

Sorting and Filtering - Cursor Control preserves almost all of Excel’s features such as sorting and filtering

Data Validation – Cursor Control prevents copy/paste operations (or autofill) from wiping out data validation.

Cursor Control is available as a free Excel add-in: Cusor.xlam. As an add-in it can be applied to any worksheet without VBA. If you prefer tighter control, Cusor.xlam’s source code is unprotected permitting its code to be copied directly into other projects. This PDF explains how to: download Cursor Control;; add it as an add-in; use it; and directly incorporate its code it into any project.

Discuss this post or other BXL topics at: facebook.com/BeyondExcel

 

September 1, 2014  8:36 AM

Dynamic Toolbar

Craig Hatmaker Craig Hatmaker Profile: Craig Hatmaker

DynamicToolbar

Add a ribbon like interface to your Excel project quickly and easily with this free add-in.  And for developers, source code is included and open to inspect or modify.

Dynamic Toolbar Video

What is the Dynamic Toolbar?
The Dynamic Toolbar is a floating UserForm configured by entries in an XL table.  It looks and acts very much like the MS Office Ribbon interface but requires a fraction of the time, effort, and skill to produce.  If you need a Ribbon Interface your choices are Dynamic Toolbar or:

Paste Buttons on Worksheets
From Developer tab find Controls group and use Insert to paste a controls to the worksheet, add text, set some properties and assign a macro. It’s easy but takes up worksheet space and limits our user interface to one worksheet or we must replicate all controls to other worksheets. It looks less professional.

The Office Custom UI Editor
This free standalone application modifies any MS Office Ribbon. It uses existing MS Office icons. It looks very professional but requires ribbon configuration using XML in a separate application. We cannot use it to modify the Ribbon from within XL.

AJP’s RibbonX Visual Designer
Andy Pope’s add-in is free and provides a graphical editor. It is a welcome step up from editing XML directly.

Ribbon Commander
Spreadsheet1’s add-in is free for trial use.It does everything The Office Custom UI Editor does with VBA instead of XML and from within XL so our interface can change while our XL apps are running.  This is fantastic if you need the power and if you have the skills.

Dynamic Toolbar adds a customizable floating Ribbon-like interface for XL applications like PapaGantt’s toolbar shown above.  Dynamic Toolbar is by far the easiest to learn and use because we configure it using normal Excel tables instead of XML or VBA; and because it requires only a handful of properties.  It also shares Ribbon Commander’s ability to change the toolbar while our app is running (although, Dynamic Toolbar only works with Excel where as Ribbon Commander works with all MS Office apps).

Dynamic Toolbar cannot do all the MS Office Ribbon does and cannot tap directly into MS Office icons, but it does enough of what the MS Office Ribbon does; is easy to add custom icons to, and is instantly recognizable so users  know how to use it.  Best of all, it can be assembled with a fraction of the time, effort and skill of alternatives. It also happens to be a great way to learn about adding, placing and manipulating all kinds of controls on a UserForm through VBA.

Start by downloading the user’s guide (pdf).


July 12, 2014  8:45 PM

Need to make your data more PivotTable friendly?

Craig Hatmaker Craig Hatmaker Profile: Craig Hatmaker

Learn to convert cross tab data into tabular data to which we can apply PivotTables,
Filters, and Sorts.

A Common Problem
The bottom table at right is an example Cross tab table.  It looks great and is easy to add data to when small.  But even when small, try summingTerritory sales from it.

If we are good with formulas, we rate this a trivial task until we consider, “what happens when we add a month?”  Suddenly traditional formulas start to get a little messy. And what happens when we finish the year?  Will we extend the table and re-label all columns to include year and month?  Or will we create a new worksheet for the next year and start this table all over again?  Hmmm… what would a total formula across multiple worksheets look like then?

Again, those of us with formula skills know this is possible.  Good for us.  But why go through all that effort when PivotTables sum data without formulas? No matter how quick we are with formulas, we can create PivotTables over tabular data in a fraction of the time with superior results. PivotTables provide slicers, drilldown, PivotCharts and a whole lot more.

The benefits of well-structured data far outweigh the aesthetics of cross tab formats.  That does not mean we have to abandon aesthetics when aesthetics count because we can present tabular data in PivotTables easily.

The UnPivot add-in makes converting cross tab data to PivotTable friendly, Auto-Filter friendly, Dynamic Form friendly, formula friendly, database friendly tabular formats quick and effortless.  Plus, UnPivot provides a bonus feature that allows us to use cross tabs as input forms and append data entered into these forms to our master table so we can perform XL miracles over tabular data AND have the ease of entry associated with cross tab data..

Here’s how to get UnPivot.  And yes, it’s free and the code totally unprotected so those new to VBA can learn from it or modify it as needed.

Discuss this post or other BXL topics at: facebook.com/BeyondExcel


May 15, 2014  1:43 PM

Creating Dynamic Forms -or- Forms that Create Themselves

Craig Hatmaker Craig Hatmaker Profile: Craig Hatmaker

Want a data entry form that creates itself?

Dynamic Form

Dynamic Form

Forms make presenting and changing information in remote tables possible. Dynamic Forms make creating those forms effortless. Read on to learn how to create forms that design themselves to accommodate any XL table complete with data validation. The user just selects a row, presses SHIFT-CTRL-D, and the form creates itself instantly.

Why I Did This
I created an app to design my kitchen. The app uses XL’s shapes to draw floor plans and cabinet positions. Each shape had to be precisely drawn and positioned which required entering dimensions into a table. But having the table on the drawing’s worksheet was clumsy and ugly. I needed to work with shapes on one worksheet and enter dimension in a table on a different worksheet at the same time. That requires a form.

Options 1 – Create UserForm Manually
I considered creating a form the old fashion way:

  • manually adding labels and text boxes
  • setting each control’s properties
  • coding routines to move data between the table and the controls
  • coding validation routines
  • etc.

For the particular table I was working with, that meant 21 labels, 20 text boxes, 1 combo box, and 2 command buttons. That seemed like a lot of duplicate work considering the table had the data validation already.

Option 2 – Use XL’s List Form
Since 2003, XL has had an option to create dynamic forms over lists using a single line of code (see: Add Forms to Edit Tables). Unfortunately XL’s dynamic form has two shortcomings: it only works with the active worksheet and it can’t start on a specified table row.

Option 3 – Create a Dynamic Form
I wanted a method that:

  • created the form for me using the table’s data validation, column headings, and cell protection
  • worked over tables not necessarily on the same worksheet
  • worked only on rows I specified.

Solution – frmData
frmData
is a blank user form with:

  • OK and Exit command buttons
  • a textbox for user messages
  • code to add all other controls based on the table sent to it.

frmData is really all I needed but I wanted more.

Enhancement #1 – clsInpMsg
I also wanted the data validation’s input message displayed when editing a table’s cell. For that I created class clsInpMsg. clsInpMsg responds to labels, textboxes, and combo boxes being selected or the mouse hovering over them and puts the associated cell’s data validation input message in frmData’s user messages textbox.

Enhancement #2 – clsForm
I also wanted the form to be a little more dynamic and fun than the standard drab gray user form. So I included class clsForm. clsForm adds a worksheet’s theme colors and “glowing” effects for command buttons when the mouse hovers over them. If you want normal, just remove two lines from frmData and (optionally) remove clsForm.

Final Result
DynamicForm.xlam is an Add-In with all forms and classes assembled together for easy workbook integration.

AddInDemo.xls demonstrates the DynamicForm Add-in and shows how to dynamically install/uninstall add-ins when projects open/close.

Want it? Get it.
Here is a PDF explaining everything: DynamicForm.PDF

 


August 30, 2013  7:17 AM

Want a Free Gantt Chart App?

Craig Hatmaker Craig Hatmaker Profile: Craig Hatmaker

Introducing a new approach to Gantt Charts in XL – BabyGantt.xls

BabyGantt.xls
There are quite a few XL based Gantt Charts out there.  They fall into 2 main categories: Bar Charts and Conditional Formatting.

Bar Charts
This type creates a stacked bar chart with the first series being the duration from project start to task start.  This series’ fill color is set to “No Fill” so it appears that the second series – the actual task – is floating by itself.  It is a clever and effective means to small Gantts – about 30 or less tasks.  It can leverage XL2007 and later’s improved aesthetics.

Conditional Formatting
This type uses spreadsheet cells and conditional formatting to make colored cells into Gantt Chart bars.  This method can accommodate many more tasks but also creates a lot of formulas and calculations.

Introducing BabyGantt.xls
BXL’s Baby Gantt uses shapes and VBA.  It has the advantage of Conditional Formatting’s “many tasks” without the formula overhead. It also shares the Bar Chart’s improved graphics capabilities.  But best of all, there’s no setup – at least – not for the chart.

All Gantt Charts require tasks and dates. But that’s all Baby Gantt requires us to enter.  We don’t need to add and configure charts or enter and autofill formulas across massive ranges.  The VBA in Baby Gantt reads our task entries and generates the graphics on the fly. And because it is Excel, we can use formulas to calculate task start and end dates.

BabyGantt.xls can be downloaded from my DropBox.  Here is a link to the instructions:
https://dl.dropboxusercontent.com/u/13737137/Projects/Gantt/BabyGantt.pdf

The instructions include:

User Instructions – Step by Step guides on how to enter your project with examples
Download Instructions – Links to a fully functioning, totally free, unprotected BabyGantt.xls
Technical Documentation – All of the code with explanations and all data validation entries with screenshots.

Baby Gantt is a good solution for small projects but its real purpose is to teach VBA developers how to manipulate shapes with VBA.  So all of the code is exposed and trimmed to be as easy to decipher as possible.  Unfortunately, the stripped down code also makes it a bit fragile.  For those ready for a more robust solution, see: Moma Gantt.
Mama Gantt is better.  Moma Gantt includes all of Baby Gantt’s features but in a more “Production Quality” state.  It leverages VBA’s classes and adds controls to prevent users from inadvertently doing things they shouldn’t.  Like Baby Gantt, it is intended as a teaching tool for VBA developers looking to take their skills to the next level with VBA’s classes.
https://dl.dropboxusercontent.com/u/13737137/Projects/Gantt/MamaGantt.pdf
Papa Gantt is best.  It provides more project management tools such as work breakdown structures, assignments, durations, task types, and more.  It is intended as a “poor man’s” alternative to full featured project management programs.
https://dl.dropboxusercontent.com/u/13737137/Projects/Gantt/PapaGantt.pdf


May 28, 2013  1:23 PM

SQL, UDFs, and *DTAARA (Data Areas)

Craig Hatmaker Craig Hatmaker Profile: Craig Hatmaker

Getting data from IBM’s iSeries into XL is normally no different than other platforms.  There are exceptions.  The iSeries’ multi-member files, such as source files, are problematic for SQL.  So are data areas.  This post deals with simple Data Areas.

To read simple Data Areas from SQL we need a little help from IBM’s iSeries.  We need a “stored procedure” which we must create, which means we must program on the iSeries. This post assumes you have access to your iSeries via a “green screen”.  If you don’t know what I’m talking about, bale now because this won’t make any sense to you.

 

Procedure:

I’m going to use an example to help explain things. In this example imagine we have a data area containing a numeric ID.  The steps to create this stored procedure are:

  • Code CL source to pass parameters and retrive data area’s contents
  • Create a CL Module from the code source
  • Create a Service Program from the CL Module.
  • Code an SQL Script to create a stored procdure using the Service Program
  • Run the SQL script

The first step is to write the CL source.  Let’s put it in member GetMyData in QGPL/QCLSRC.  Here is the example:

    PGM        PARM(&ID)                                                                                      
    DCL        VAR(&ID) TYPE(*DEC) LEN(10 0)                                                                                
    RTVDTAARA  DTAARA(MYDATA) RTNVAR(&ID)                                                                                                       
    ENDPGM

The next step is to create the CL Module.  At a command prompt type:

   CRTCLMOD  MODULE(QGPL/GetMyData) SRCFILE(QGPL/QCLSRC)

After the above executes succesfully, type this command:

  CRTSRVPGM SRVPGM(QGPL/GetMyData) MODULE(QGPL/GetMyData) EXPORT(*ALL)

Next we write our SQL Script.  Create source member GetMyData in QGPL/QDDSSRC:

  Create Function
    GetMyData()  
    Returns DECIMAL(10, 0)
    Language            CL
    Specific            GetMyData
    Deterministic
    No SQL
    Returns Null on Null Input
    No External Action
    Not Fenced
    External Name       'QGPL/GetMyData(GetMyData)'
    Parameter Style     SQL;

Lastly, we run the SQL script from a command line:

  RUNSQLSTM SRCFILE(QGPL/QDDSSRC) SRCMBR(GetMyData)

Now all that is left to do is test it.  Using command STRSQL to start an SQL session, run this SQL statement:

  Select GetMyData() From SYSIBM/SYSDUMMY1

SYSIBM/SYSDUMMY1 is a special one record file we can use for this sort of thing.

 

Summary:

As you can see, there’s not a lot of work involved once you know how.  And if you look carefully, you can see many possibilities for doing things far beyond reading simple data areas!

 

References:


April 18, 2011  11:47 AM

“Can there be Dynamic Ranges for VLOOKUP and Data Validation List for an Invoice?”.

Craig Hatmaker Craig Hatmaker Profile: Craig Hatmaker

This question was posed and answered by “Mr. Excel” and “Excel is Fun” in a recent YouTube post by the same title.  Their solutions work well.  I’m going to answer with what I believe is a better approach.  It uses Tables. Tables have some great characteristics:

Dynamic Tables grow/shrink as rows/columns are add/deleted.
Nieghbor Aware Tables automatically move other tables as they grow (with some restrictions)
Structured References In Excel 2007 and higher (XL’07+), tables create special names so we can address a table’s column by its heading. Ex: =Table[Column]
Stylish Table Styles  (in XL’07+) dramatically improve data formatting.
Links They can link to external data.
Duplicate Removal XL’07+ includes a menu option to remove duplicate rows.

Creating tables is easy.  If you have a range that contains data, simply select any cell in the range and use the keyboard shortcut: CTRL-L (in XL2007 and later you can also use the more intuitive CTRL-T).   Once a table has been created, you can change its name by selecting any cell in the table and using the menu tab Table Tools.  The Table Name input box is on the left in the Properties grouping.    

Tables have some drawbacks.

Not Supported Prior to XL’03 So if you’re using old versions of Excel, use the “Mr.Excel” or “Excel is Fun” approach – or upgrade and start using Excel’s Tables.
External Data Source Restriction MS Query and Data Validation can’t see tables without a Named Range Wrapper. 

A Named Range Wrapper (NRW) is simply a name assigned to a range.  To create an NRW for a table just select the table’s entire range and assign a name by typing it into Excel’s Name Box or using the menu path Formulas >  Define Name.   If you are working with a .xls, you’re done.  But if you’re working with a any of the new formats (.xlsx, .xlsm) you must change the name’s  Refers to: reference from a table reference to A1 notation.  That’s it.  The new range is every bit as dynamic as the best dynamic named range formula – without the formula.   

 

“Can there be Dynamic Ranges for VLOOKUP?”
In XL’07+ VLOOKUP works with tables already.  If you have a table called “Products” you can use it in VLOOKUP like this:

=VLOOKUP(“ABC”, Products, 2, 0) 

Where “ABC” is the value in the first column of Products you’re searching for.  In XL’03 VLOOKUP needs an NRW.  Once the NRW is created, we use it as we did above. 

 

“Can there be Dynamic Ranges for Data Validation?”
Data Validation does not recognize tables but we can still use them. We can either apply a “Named Range Wrapper” over the table and use the name in Data Validation or we can exploit a quirk of using tables.

QUIRK! Any reference placed over a table becomes dynamic, even absolute cell addresses.

So if we have a table in cells $A$4:$C$10 and we want our Data Validation rule to use the first column’s values (excluding the header) as a list, we can put =$A$5:$A$10 in Data Validation’s Source: box. Now if we add entries to our table, the Source box’s values will change automagically! How cool is that!

Summary:
Clearly, tables are far simpler than the “Mr.Excel” and “Excel is Fun” approaches (both good approaches, both compatible with older XL, neither requiring VBA).  Note that we will never have to worry about other tables on the worksheet like we would with the traditional “COUNT” approaches.  We don’t have to worry about the table’s location – ever. We don’t have to worry about blanks, or numeric data, or character data or any combinations thereof that can throw off COUNT methods.


April 7, 2011  3:41 PM

Getting User Names from Outlook Into Excel

Craig Hatmaker Craig Hatmaker Profile: Craig Hatmaker

The company president’s mother died.   The staff wanted to express their sympathy.  Cards were purchased and now we needed to make sure everyone got a chance to sign them.  We needed names on a check list to circulate with the cards so when someone signed, they could check their name and hand the card to someone whose name remained unchecked.  So how do we make a list with everyone’s name and make sure no one is left off?

Everyone in our office has a computer.  Everyone uses Outlook.  All we needed was a quick way to get all user names into Excel to edit, format and print.  This is different from the contact list.  The contact list may, or may not have all users in it and it definitely has far more names than users. 

NOTE! Requires Excel 2003 or later because of ListObject

  1. Open Excel and get to the VBE (Alt-F11)
  2. Use Ctrl-R to bring up the Project Explorer
  3. Double click ThisWorkbook to bring up its code window
  4. Enter this code then run it. 

Sub Network_Users()

     Date   Ini Modification
‘   04/10/11 CWH Initial Programming
‘   04/03/14 CWH Added email addresses

    Dim olA     As Object       ‘Outlook.Application    Start Outlook (OL)
    Dim olNS    As Object       ‘Namespace              OL identifiers context
    Dim olAL    As Object       ‘AddressList            An OL address list
    Dim olAE    As Object       ‘AddressEntry           An Address List entry
    Dim lo      As ListObject   ‘An Excel Table

    On Err GoTo ErrHandler

‘   Create a ListObject/Table in the spreadsheet
    With ActiveSheet
        .Cells.ClearContents                    ‘Clear worksheet completely
        .Cells.ClearFormats                     ‘Clear formats as well
        [A4:B4] = Array(“Names”,”Email”)        ‘Add a column headings
        Set lo = .ListObjects.Add(1, [A4].CurrentRegion, , xlYes)
        lo.Name = “Names”
    End With 

‘   Open Outlook, set context, open “All Users” address list
    Set olA = CreateObject(“Outlook.Application”)
    Set olNS = olA.GetNamespace(“MAPI”)
    Set olAL = olNS.AddressLists(“All Users”) 

'   Add each address entry name to the Excel Table
    For Each olAE In olAL.AddressEntries
        With lo.ListRows.Add
            .Range(1) = olAE.Name
            .Range(2) = olAE.GetExchangeUser.PrimarySmtpAddress
        End With
    Next   

‘   Format Results
    lo.HeaderRowRange.Style = ActiveWorkbook.Styles(“Heading 1″)
    [A5].Select
    ActiveWindow.FreezePanes = True
    Cells.EntireColumn.AutoFit   

‘   Do this ONLY if you want to close Outlook
   ‘olA.Quit   

ErrHandler:    If Err.Number <> 0 Then MsgBox _
         “Network_Users - Error#" & Err.Number & vbCrLf & _
         Err.Description, vbCritical, "Error", Err.HelpFile, Err.HelpContext
     On Error GoTo 0   

End Sub


March 3, 2011  1:12 PM

My Top 10 “Freebies” for the Midsize Enterprise IT Director

Craig Hatmaker Craig Hatmaker Profile: Craig Hatmaker

I’m departing from my usual post to share these gems with our community.  Here are my top “10″ freebies:

#1 XenServer – Virtualize your physical servers with this free hypervisor.

#2 MySQL and MS SQL Server Express – Manage your data with these free professional class databases.

#3a Microsoft Visual Studio ExpressDevelop fully functional, professional windows based applications with this little brother to Microsoft’s enterprise platform.     

#3b Visual Web Developer Express – Create dynamic professional websites with this free version of Microsoft’s enterprise web development platform.

#3c VBA – You may not even know that if you have Excel, Word, Access, PowerPoint, Visio, Project, or Outlook … you also have a powerful development platform that can even (gasp) update mainframe databases.  And that VBA you use in Office products is almost identical to the VB code in Visual Web Developer Express’ Active Server Pages.

#3d Microsoft Visual Studio Express for Phone – Need to create mobile apps?  Start here.

#3e Microsoft Excel – Well, Excel isn’t free, but all you need for a roll-your-own Business Intelligence/Business Analysis solution is there.  Many BI/BA solutions either use Excel directly as their front end, or their human interface looks a lot like it.  All you have to do to make Excel emulate the big boy BI/BAs is some VBA code and a link to the data.

#3f MS Query – Bundled in every version of Excel, MS Query can link to any database and provide a graphical view of your company’s information. 

#4 Skype – Free video calls to anywhere on the planet. Need to support remote PCs? Chat and share desktops.  And if a picture is worth a thousand words, use Skype on a webcam laptop to show “Peggy” that dead server in your rack so you don’t have to repeat yourself a thousand times.

#5 Dropbox – Automatically sync local documents to cloud storage and access them from any computer connected to the web.  Share them with anyone you choose or make them available to the public.  No FTP skills required.

#6 Youtube – Broadcast training videos, product demonstrations, how-tos, president’s message, whatever to a select few or the entire world for nothing.

#7 Linked In – Network with other professionals in your field.  No dues required.

#8 Google/Bing/Yahoo/et.al.  – Okay, I know.  These are not new.  But how much are you paying for answers to tech questions available free from these web search engines? 

#9 Facebook – Facebook?  For the IT Director?  Really?  Yep.  Throw that paper newsletter in the recycle bin and join the social media revolution.  Put you company’s events, anniversaries, employee recognition, and more on Facebook and lock it down to employees only.  Save paper.  Save trees.  Save time.  Save money.

#10 SurveyMonkey – Need to know what people think of your product, your company, YOU?  Collect results via weblink, email, or Facebook .  Click here to take my 3 question survey.

#11 Craig’s List – I had to add this one.  We’ve been using Craig’s list to advertise job openings and the responses from it far outnumber paid media advertisements.  Some of the applicants are even quite good.

 


February 24, 2011  6:53 PM

Solving Dynamic Ranges with Tables/ListObjects

Craig Hatmaker Craig Hatmaker Profile: Craig Hatmaker

Dynamic named ranges have been a subject of interest on Excel boards for sometime.  Lots of people want to know what’s the best way to create a named range that expands (or shrinks) according to the data entered, and can be used in formulas like VLOOKUP without change.  For some background on this subject see: Dynamic Ranges – Overcoming Shortcomings.  In that post I promised to talk about what I believe is truly, the one best way to handle this kind of thing, Excel’s Tables.

Tables!

In 2003, Excel introduced something called a “ListObject” also known as a “Table”.  There are several features packed into Tables, but the main feature of importance in this discussion is their ability to grow or shrink dynamically.  Out of the box, a table is a dynamic named range.  So why agonize over what formula best creates one?

Creating tables is easy, simply select any cell within the desired range of data and press Ctrl-L (in Excel 2007 or 2010 you can also use Ctrl-T).  Excel will probably guess correctly what range you meant but gives you the opportunity to specify exactly what you want.  Whenever your selected cell is in a table Excel adds the Table Tools tab to its ribbon. There you can change the table’s name using the convenient “Table Name:” box in the upper left corner.

Unlike formula approaches, tables don’t mind other tables on a worksheet.  And Tables come with right click menu functions for adding/inserting/deleting rows/columns.  As you add rows or columns, the table automatically encompasses the new data, extends formats and formulas, and when rows are inserted, moves tables below to make room. 

Tables are superior to named ranges in every way except one: they can’t be used as datasources.   That’s easily overcome.  Simply select the range you want to use as a datasource (that can be the entire table, just the data, a column…) and give it a name using the name box in the upper left corner of each worksheet, or using the name manager.  The new name is every bit as dynamic as the best dynamic range formula – without the formula.

It’s Time to Move Ahead

At the time of this blog post, I still meet Excel fans enthusiastic over dynamic ranges.  When asked “why not tables?” I usually get a blank stare.  Some point out tables don’t work with all versions of Excel.  True enough.  But it’s been almost a decade now since XL 2003 came out.  I’ve long since upgraded every user in the company I work for to Office 2003 or higher.  I’ll bet your company has too.  So put your favorite dynamic named range formula in a frame and hang it on the wall with other momentous from your past.  It’s time to move ahead with tables.


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: