+ Reply to Thread
Results 1 to 4 of 4

Macro to make the background color of a cell match that of another cell

  1. #1
    Registered User
    Join Date
    10-04-2014
    Location
    New Zealand
    MS-Off Ver
    2010
    Posts
    2

    Macro to make the background color of a cell match that of another cell

    Hi there. This is my first time I have needed to ask a question. Whenever I've had problems in the past, I've found an answer but in this case I want to do something specific and if anyone has asked it before, I couldn't find it.

    The title says what I need. Here's what I have so far:

    Please Login or Register  to view this content.
    I was previously using Interior.ColorIndex but since I want to use colors that weren't preset, this wasn't going to work. Interior.Color seems to do the trick but because I want to get the color using my GetColor function, I'm now stuck. As far as I can tell, the above code should work if I can replace the question marks with the correct type - I just can't figure out what it should be.

    If anyone can help, I would be very grateful.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to make the background color of a cell match that of another cell

    Hi, LukeWarmwater,

    type would be Long, itīs Sheets and not Sheet.

    Why not use
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    10-04-2014
    Location
    New Zealand
    MS-Off Ver
    2010
    Posts
    2

    Re: Macro to make the background color of a cell match that of another cell

    Wow, "long"? It was that simple? That makes me feel foolish. But at least I know the answer now and am not likely to forget it.

    As for why I didn't use the code you suggested, funnily enough it was to make it simpler. I was going to be rewriting "Sheets("Colours").Cells(1, 1).Interior.Color" quite a lot targetting different cells so I made functions so that I didn't have to keep remembering which cells contained the color templates I wanted.

    Thanks for your help.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to make the background color of a cell match that of another cell

    Hi, LukeWarmwater,

    I would pass the information about Sheetname and Range as parameter instead of rewriting the function and maybe add an error handler to it in case no correct values are being delivered.
    Please Login or Register  to view this content.
    Ciao,
    Holger

+ 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. 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
  2. Macro Based on Cell Background Color
    By Kinchen in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-06-2011, 02:11 PM
  3. [SOLVED] Cell Background Color Macro
    By boldcode in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-07-2011, 02:35 PM
  4. [SOLVED] Macro for Changing Cell Background Color
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-02-2005, 01:45 PM
  5. macro to change cell background color
    By rocket0612 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-21-2005, 09:46 AM

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