The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,861 other subscribers

Archive for the ‘Excel’ Category

Why I really dislike localized error messages…

Posted by jpluimers on 2012/09/06

The problem with localized error messages often is that it is virtually impossible to find information about them.

For instance the below error got reported by a client for me to fix (click on the picture to get a larger version) has a few big problems:

Read the rest of this entry »

Posted in Excel, Office, Power User, Windows | Tagged: , , , , , , , , , , , , , | 2 Comments »

When you wished that Excel had short-circuit boolean evaluation: Excel IF, OR and SEARCH function combination

Posted by jpluimers on 2012/09/04

I had a function like this in Excel:

=IF(OR(B2=""; SEARCH(C2;B2)); "ok"; "INCONSISTENT")

The situation should be OK when either:

  • Cell B2 is empty (an empty cell is considered equal to a zero length string).
  • One or more occurrences of the value in cell C2 can be found in the value of cell B2

Since most of my software development is outside of Excel, I’m used to short-circuit boolean evaluation.

Not with Excel: the OR is a function, not an operator, so all other function calls will be evaluated.

Since SEARCH will return #VALUE! when the first argument does not have a value, and #VALUE! propagates in a similar way as NULL in SQL does (SQL has the Boolean datatype inconsistency though).

So you need to get rid of #VALUE! as soon as you can using the one of the IS functions like the ISERROR function or the ISNUMBER function.

ISNUMBER, contrary to popular belief, not only distinguishes numbers from text, but in fact from any non-numeric value as Glaswegian kindly explained on the TechSupport forum:

Excel IF and SEARCH function combination

I am trying to do the following:

If cell A1 contains the characters “ABC” anywhere in the string or value, then “Y”, else “N”. I almost have it by using =if((search(“ABC”,A1)),”Y”,”N”). However, with the “else” if “ABC” is not found, it returns ! as opposed to “N”.

[…]
Try

=IF(ISNUMBER(SEARCH("abc",A1,1)),"Y","N")

ISNUMBER checks the type of value and returns TRUE or FALSE. The error refers to the fact that Excel could not translate the value to the type required.

So the code ends up as this:

=IF(OR(B2=""; ISNUMBER(SEARCH(C2;B2))); "ok"; "INCONSISTENT")

–jeroen

via: Excel IF and SEARCH function combination – Tech Support Forum.

Posted in Development, Excel, Office, Power User, Software Development | Leave a Comment »

Office 2010/2007: Ribbon minimize mode: maximize space by “Auto-Hiding” the Ribbon in Office (via: How-To Geek)

Posted by jpluimers on 2012/06/08

The ribbons in Office 2010/2007 take up a lot of sceen estate.

Luckily, it is easy to maximize space by “Auto-Hiding” the Ribbon in Office 2010/2007: put the Ribbon in “Minimize Mode”.

The Ribbon will un-hide when you:

  • click on one of the Ribbon tabs
  • press the Alt key followed by a letter corresponding to a Ribbon tab

How-To Geek explains (with screen shots) how to put the Ribbon in “Minimize Mode”:

To put the Ribbon into minimized mode, just right-click an open area on the Ribbon and choose Minimize the Ribbon.

Edit:

In addition to that (thanks Matthijs!) you can switch the Ribbon to/from auto-hide behaviour by double-clicking on a ribbon tab.

–jeroen

via: Maximize Space by “Auto-Hiding” the Ribbon in Office 2007 – How-To Geek.

Posted in Excel, Office, Power User, Word | 2 Comments »

.NET/C#: reading/writing Excel workbooks and worksheets

Posted by jpluimers on 2012/06/06

Basically there are many ways to read/write Excel workbooks and worksheets:

  1. Use the open source EPPlus .NET assembly (which is based on ExcelPackage)
  2. Use the open source ExcelLibrary which seems to be derived from PHP ExcelWriter
  3. Use OleDB to read/write Excel with either the JET (Office <= 2003) or ACE (Office +> 2007) drivers
  4. Use COM/OleAutomation/Interop/VSTO

The latter is used by many many people, and has two big drawbacks:

  • it requires Excel to be installed
  • it is painfully slow

The others can run server side as they do not require Excel to be installed. They are also much faster.

I’ve used OleDB, and it is sort of OK, but hard work.

EPPlus is much faster and versatile and seems to be the most active open source project.

–jeroen

Posted in .NET, .NET 4.5, ASP.NET, C#, Development, Excel, Office, Software Development | 2 Comments »

Microsoft Excel 2007/2010 – Protecting Workbooks and Worksheets

Posted by jpluimers on 2012/05/04

One of the things about the Office 2007 and 2010 Ribbon is that it makes the things that you have remembered for 10+ years go into hard to find places.

My point is that according to the ribbon documenation:

A ribbon can replace both the traditional menu bar and toolbars.

Microsoft has decided to read the “a ribbon can replace” as “the ribbon replaces”. Thereby also introducing a whole new naming for the UI elements used in ribbons (see at the bottom).

Tab "Review"; Group "Changes"; Commands "Protect Sheet" / "Protect Workbook"

Tab “Review”; Group “Changes”; Commands “Protect Sheet” / “Protect Workbook”

Protecting a worksheet and workbook have been in the menu “Tools”, submenu “Protection” forever. But alas: No more “Tools” menu, and accompanying keyboard shortcut productivity (and I needed “unprotect workbook” because you cannot copy workbooks inside a protected workbook).

As “password protect worksheet” shows, it is now under:

  1. Tab: Review
  2. Group: Changes
  3. Commands: Protect Sheet / Unprotect Sheet / Protect Workbook / Unprotect Workbook

–jeroen

via: Microsoft Excel 2007 – Protecting Workbooks.

Naming of ribbon UI elements

Naming of ribbon UI elements

Posted in Excel, Keyboards and Keyboard Shortcuts, Office, Power User | Leave a Comment »

Start a New Line Inside a Spreadsheet Cell in Excel | Excel Semi-Pro

Posted by jpluimers on 2012/03/16

Unlike most tools where you use Shift-Enter to add a line break character (ASCII 10: line feed), Excel is different:

Sometimes it’s necessary to have more than one line inside a worksheet cell, which is easily done with a line break.

Add a new line by holding down the Alt key while you press enter. It’s the keyboard shortcut Alt+Enter. In Excel 2008 and 2011 for Mac use Cmd+Option+Enter.

–jeroen

via: Start a New Line Inside a Spreadsheet Cell in Excel | Excel Semi-Pro.

Posted in Excel, Keyboards and Keyboard Shortcuts, Office, Office 2000, Office 2003, Office 2007, Office 2010, Office 2013, Office 2016, Power User | Leave a Comment »