+ Reply to Thread
Results 1 to 5 of 5

Copy Background Color Only

  1. #1
    Registered User
    Join Date
    12-29-2016
    Location
    United State
    MS-Off Ver
    O365
    Posts
    36

    Copy Background Color Only

    Hi All,

    Is there a VBA code to let you select a range (that have hidden rows or columns) on one workbook, copy only the background colors from the visible cells, then let you select a cell on other workbook or worksheet to paste the background colors (not other formatting). The result should be, the destination selected showing the background colors from the visible cells of the original selection.

    Note: The destination does not have hidden rows and columns, so that is not an additional issue.

    Thanks in advance
    -Raul

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Copy Background Color Only

    Hi Raul,
    Welcome to the forum.
    The background colour is addressed in VBA as InteriorColor
    This is a long integer
    Dimension a variable for this myintcolor as Long
    you tell myintcolor that it's equal to the cell's interior color and then the other cell you say the the cell interiorcolor = myintcolor

    Something like that
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    12-29-2016
    Location
    United State
    MS-Off Ver
    O365
    Posts
    36

    Re: Copy Background Color Only

    Thank you Keebellah,

    This is what I have so far and it works to paste the visible cells only, but it paste all the formatting. Also, it only works by selecting and pasting one column at a time. Is there a way to modify, so it let you select data across multiple columns and paste only the background color ?

    Thanks,
    Raulito

  4. #4
    Registered User
    Join Date
    12-29-2016
    Location
    United State
    MS-Off Ver
    O365
    Posts
    36

    Re: Copy Background Color Only

    Opps forgot the code Keebellah,

    This is what I have so far and it works to paste the visible cells only, but it paste all the formatting. Also, it only works by selecting and pasting one column at a time. Is there a way to modify, so it let you select data across multiple columns and paste only the background color ?

    Sub Copyvisible_ColumnsFormat()
    Set from = Selection.SpecialCells(xlCellTypeVisible)
    Set too = Application.InputBox("Select range to copy selected cells to", Type:=8)
    For Each Cell In from
    Cell.Copy
    For Each thing In too
    If thing.EntireRow.RowHeight > 0 Then
    thing.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Set too = thing.Offset(1).Resize(too.Rows.Count)
    Exit For
    End If
    Next
    Next
    End Sub

    Thanks,
    Raulito

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Copy Background Color Only

    The code is in Post #2,

    The InteriorColor you can als use the directwindow to test it on a selected cell:

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy value with color background and comment ( Macro/VBA)
    By ilyasss in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2020, 12:51 PM
  2. Copy background color if values are equal
    By elecgenius in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-09-2016, 03:34 PM
  3. Replies: 0
    Last Post: 06-24-2015, 06:26 AM
  4. Change cell background color based on another cells background color
    By Queo in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 4
    Last Post: 06-10-2014, 05:28 AM
  5. Automatically copy cell background color - NO VALUES
    By blast00 in forum Excel General
    Replies: 5
    Last Post: 12-17-2012, 08:54 AM
  6. Find cell with identical value and copy it's background color
    By PvanS in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2012, 10:21 AM
  7. [SOLVED] Macro to change all cells with a certain background color in another background color
    By kevinvzandvoort in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2012, 11:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1