+ Reply to Thread
Results 1 to 7 of 7

Color cells RGB colors, error 1004

  1. #1
    Registered User
    Join Date
    05-03-2012
    Location
    lithuania
    MS-Off Ver
    Excel 2007
    Posts
    44

    Color cells RGB colors, error 1004

    Hello,

    I try to make this code work I found on another forum.
    http://www.mrexcel.com/forum/showthr...=396217&page=2
    http://www.mrexcel.com/forum/showthr...=365423&page=3

    I try to color Sheet1 cells D column to the color values set in Sheet2 Columns ABC
    I get error 1004, see attached file. Also How can I add button to refresh the values, or to refresh them when I
    open my workbook?

    Sub ColorMe()
    Range("Sheet1!D1:D8").Interior.Color = RGB(Range("Sheet2!A1:A8").Value, Range("Sheet2!B1:B8").Value, Range("Sheet2!C1:C8").Value)
    End Sub

    Thank you.
    Attached Files Attached Files
    Last edited by smile0; 05-24-2012 at 03:27 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Color cells RGB colors, error 1004

    The RGB function accepts three scalar arguments, not three arrays.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    05-03-2012
    Location
    lithuania
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Color cells RGB colors, error 1004

    Quote Originally Posted by shg View Post
    The RGB function accepts three scalar arguments, not three arrays.
    I'm not a programmer, how can I color the cells I described in my colorme.xls file?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Color cells RGB colors, error 1004

    Please Login or Register  to view this content.
    Open the VBE, do Insert > Module, and paste the code in the window that opens.

  5. #5
    Registered User
    Join Date
    05-03-2012
    Location
    lithuania
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Color cells RGB colors, error 1004

    I get no errors but it just sets all Sheet1!D1:D8 colors to black, no matter what is entered in Sheet2 ABC columns

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Color cells RGB colors, error 1004

    Missed the different sheets ...

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-03-2012
    Location
    lithuania
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Color cells RGB colors, error 1004

    Thank you it certainly works OK. I have a few questions regarding usage:

    1. For every range that I need I have to make new module and adjust the code?
    I jsut cope the sub end sub routines and gave them different names.
    2. Is it possible to add a button to update the colors
    I found out it is easy just add a button and assign a macro in developer design mode.
    3. Is it possible to make colors auto refresh when the workbook is opened?
    You have to navigate to VBA then to open ThisWorkbook and paste this code:

    Please Login or Register  to view this content.
    Last edited by smile0; 05-24-2012 at 06:43 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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