SpecialCells in VBA

How to use SpecialCells method in Excel VBA

SpecialCells in VBA is a really useful method to deploy in Excel. It returns a Range Object that only covers the type of cells you specify. You can use the SpecialCells in VBA Method to return a Range Object that only holds numbers, text, blank cells, formulae, cells with datavalidation, cells with conditional formatting, the last cell in the worksheet, cells with comments and all visible cells.

If you for example want to change formatting for all numbers in a worksheet you do not need more than one line in the Visual Basic Editor to do it.

Cells.SpecialCells(xlCellTypeConstants, xlNumbers).Style = “currency”

This line will change all numbers in the active worksheet to currency format.  The Range object Cells is used to tell Excel that you want to look at all the cells and the special cells method to decrease it to in this example only constants (xlCellTypeConstants) and again to decrease it to only numbers the criteria  xlNumbers is added to the SpecialCells Method.

Similar we can use the SpecialCells Method to return a Range Object that only holds text.

Cells.SpecialCells(xlCellTypeConstants, xlTextValues).Font.ColorIndex=3

This VBA line will change the font colour to red for all text in the active worksheet.

The SpecialCells Method syntax is;
expression.SpecialCells(Type, Value)

The Expression have to be a Range object such as Cells, Range(“A1:B200”), ActiveSheet.UsedRange etc.

The different types of special cells are:

  1. xlCellTypeAllFormatConditions (all formatted cells)
  2. xlCellTypeAllValidation (all cells with datavalidation)
  3. xlCellTypeBlanks (all blank cells)
  4. xlCellTypeComments (all cells with notes)
  5. xlCellTypeConstants (all cells containing constants (numbers or text))
  6. xlCellTypeFormulas (all cells with formulas)
  7. xlCellTypeLastCell (The last cell in all used ranges)
  8. xlCellTypeSameFormatConditions (all cells with the same formatting also conditional formatting)
  9. xlCellTypeSameValidation (all  cells with the same datavalidation)
  10. xlCellTypeVisible (alll visible cells)

You can also use a combination of the above options.

Cells.SpecialCells(xlCellTypeConstants, xlNumbers).SpecialCells(xlCellTypeAllValidation).Font.Color = vbRed

This line of VBA code will add red font colour to all cells with numbers & Datavalidation.

The SpecialCells in VBA Method is also very powerful if you want to test your data in an If Then Else decision code.

SpecialCells in VBA


In the example above all numbers are tested in the active worksheet if the value is greater than 7500. If the test is true 10% is added. The For Each loop is only running through cells with numbers.

The SpecialCells in VBA Method can be very handy if you need to remove blank rows from you Excel lists or Excel databases.


and after running the macro


In the above example The SpecialCells Method finds all blank cells in the range from A3 to A27 and deletes the entire row.

You have a lot of variations you can use and you will find out that when you start using The SpecialCells method  you will save a lot of lines in your macros!

Four benefits of Moving to Office 365

By J. Peter Bruzzese

The recent global recession is still quite fresh in everyone’s minds. From an IT perspective it forced IT administrators to tighten their belts and hold off on upgrades of both hardware and software for quite some time.
The growth of “cloud” solutions (like Office 365) has provided IT teams with another option when considering new hardware and software. Here we’ll take a closer look at the features available, benefits and a key consideration when moving to Office 365.

What is Office 365, and why move to it?

The name is somewhat confusing because it appears to be the next flavor of the Office product suite (Word, Excel, PowerPoint, etc…).  In fact, Office 365 is many things, it is a cloud-based, hosted services solution for Office applications, email, collaboration, and more.
Exchange, SharePoint and Lync have moved from a traditional on-premise hosting to Microsoft datacenters (i.e.. their “cloud”). Instead of paying for the software upfront, you pay as a monthly/annual subscription for those services (hence the term Software as a Service or SaaS).

Office 365 has a variety of different packages to choose from and some of them offer the Office Suite as part of the subscription too.  If you choose one of these plans you can put the latest flavor of Office (Word, Excel, PowerPoint, etc.) on desktops/mobile devices.  And there are a variety of other services offered with Office 365 like OneDrive for Business, Yammer, Office 365 Video and more.

There are some key reasons why a move to Office 365 can benefit your organization from the perspective of an IT team getting ready to decide on-premises vs. cloud.  Let’s consider four benefits for moving to Office 365 and one key user consideration for IT administrators.

Four benefits of moving to Office 365:

No-Cost Server Infrastructure:  If you are looking to modernize your server-side solutions the cost of upgrading your existing infrastructure could be exorbitant.  Moving mailboxes to the cloud eliminates that concern and cost.  Microsoft will worry about the hardware and storage, and you can pay as you grow for easy scalability.

No More Upgrades or Fixes:  Much of the stress of an admin is handling fixes and upgrades for solutions to ensure they are patched properly and as secure as possible.  With Office 365 this is all handled for you.

Availability:  Microsoft provides a 99.9% SLA for availability.  Whereas on-premise you would have to have redundant servers on-site and additional servers in an off-site location to provide that level of availability, Microsoft has it all in place from day one to ensure your users have consistent access to their email and other services.

Services Offered:  As mentioned earlier, Office 365 is a mix of different services.  It’s quite amazing really when you consider all the different tools provided.  You can access the services through traditional means (Outlook connected to Exchange Online) or through browser-based connectivity (Yammer or SharePoint Online through your browser).

Upon logging into your portal you are offered a variety of tools to choose from, and the list is growing!  Note the options in the figure below.  OneDrive, Sites, Delve, Video, Office Online (Word/Excel/Point/OneNote) … offering a compelling price/features proposition.

Office 365 App Launcher – benefits of moving to office 365

So we’ve covered four benefits of moving to Office 365, what could the key consideration be? Here it is…


Take a user who has been on Windows XP with Office 2003 for the past 10 years.  Give them a new laptop running Windows 7/8 (v10 coming soon) and Office 2013.  Introduce the user to the new tools for communication and collaboration like Yammer, SharePoint, OneDrive for Business and so forth.  Instead of praising your team the users vent frustration at the dip in performance as they struggle to process all the new upgrades.

Don’t do that to your people.  Going from the menu structure of legacy Office into the new ribbon interface alone will be an overwhelming task for some.  If you have gone with Windows 8, the new interface is quite a step change (even for experienced users).

Support your people.  You want to give them the latest and greatest and you want them to experience the productivity boost that should come with new hardware and software possibilities.

But you must do so through training first.

Manage the change for users through classroom training, with all the benefits of hands on exercises under the guidance and support of an experienced trainer.  Or even run workshop sessions BEFORE you put that new laptop or desktop in front of them with all the new bells and whistles.

And then you might want to provide 24/7/365 support training through a video portal, which perfectly complements any classroom based training. An eLearning portal with an easy to use interface and short searchable learning clips helps users improve and maintain performance.

We are certainly living in exciting times.  Cloud solutions like Office 365 are offering small-midsize business an opportunity to have enterprise grade solutions right at their fingertips, without all the server side heavy lifting being placed on the IT admin.  The end-users will love the new possibilities opened to them and the increase in productivity through new communication and collaboration tools.  Exciting times indeed!

J._Peter_Bruzzese J. Peter Bruzzese (Office 365 MVP) is the CIO of ClipTraining.com, providers of short, task-based video training through an online portal solution.  He is an internationally published author with over a dozen titles to his credit about Windows/Office/Exchange/etc.  He is a technical speaker for Microsoft and others.  He writes a weekly column for InfoWorld entitled “Enterprise Windows” and is a strategic technical consultant with Mimecast.  You can follow JPB on Twitter @JPBruzzese and email him at jpb@cliptraining.com

For information on eLearning services in the UK, ClipTraining partner and UK distributor, STL, can be emailed at info@stl-training.co.uk

Further reading

Office 365 Training in the ClipTraining Library
Classroom based MS Office training

36.5 Office 365 Features That Will Boost Your Productivity
What’s In & What’s Out In Office 2013
A well-trained I.T. team: Your company’s secret weapon