Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Referencing External Cell Colors.

Referencing External Cell Colors

by Allen Wyatt
(last updated July 25, 2015)

3

Beth asked how to copy the color formatting of an external cell to a cell in the current workbook. Unfortunately, there is no intrinsic way to do this by using the linking features of Excel. You can, however, copy formatting from one workbook to another by using a macro.

As an example, consider the following macro code:

Dim lMyColor As Long
Workbooks.Open Filename:="C:\mypath\myworkbook.xlsm"
lMyColor = Range("A1").Interior.Color
Windows("TargetBook.xlsm").Activate
Range("E8").Interior.Color = lMyColor

This code opens a workbook (myworkbook.xlsm) and grabs the fill color from cell A1. It then switches back to the target workbook (from which this code is assumed to be running) and stuffs the fill color into cell E8.

This approach works great if you are copying the fill color from a single cell to a single cell. If you, instead, want to copy a range of cells or copy more formatting than just the fill color, then you might be better served with this approach:

Workbooks.Open Filename:= "C:\mypath\myworkbook.xlsm"
Range("A1:B6").Copy
Windows("TargetBook.xlsm").Activate
Range("E8").PasteSpecial Paste:=xlPasteFormats, _
  Operation:=xlNone, SkipBlanks:=False, _
  Transpose:=False

Again, this code opens the external workbook. It then uses the .Copy method for a range of cells (A1:B6). After switching to the target workbook, the formats from those cells are pasted into the cells beginning at E8.

If you decide to use code like this, you can place it in the Auto_Open macro for the target workbook. Of course, you need to modify the code so that it refers to the proper path and workbook names, along with the desired source and target ranges.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11169) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Referencing External Cell Colors.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Noting Inactivity within a Timeframe

There are many times when you are creating a worksheet that you need to analyze dates within that worksheet. Once such ...

Discover More

Keeping a Replace Operation Displayed

The Find and Replace tool is designed to help you find and replace information as quickly as possible. However, you may ...

Discover More

Ruler Disappears when Entire Document Selected

The rulers in Word can be quite helpful when formatting your document. The rulers may not be displayed all the time, ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Specifying Font Color in a Formula

Do you need to change text color based on the result of a formula? This tip provides a couple of ways you can accomplish ...

Discover More

Determining Font Formatting

If you need to determine the font applied to a particular cell, you’ll need to use a macro. This tip presents several ...

Discover More

Highlighting Values in a Cell

There are many ways that Excel allows you to highlight information in a cell. This tip examines a way to highlight values ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is eight more than 6?

2015-07-26 04:38:11

Eyal

What can Ido if the format is based on conditional formating? I see that it doesn't work when you use conditional formating


2015-07-25 07:07:48

Petros

I believe Willy nailed it!

The Excel color commander FREE add-in can help you create stylish Excel dashboards or even a custom theme that can reflect your company logo colors.

The addin offers a COLOR-PICKER that can copy any color on the monitor, plus easy access to cloud color generators and ColorIndex buttons on the ribbon.

Favorite custom colors are stored on disc and shown in the ribbon! Read more:

http://www.spreadsheet1.com/excel-color-commander.html


2015-07-25 06:04:20

Willy Vanhaelen

You don't need a macro to do this. If both workbooks are open in the same instance of Excel you can perfectly copy formatting between them.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.