Results 1 to 2 of 2

ActiveWorkbook.Colors (Trying to store value based on data in cells

Threaded View

  1. #1
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    ActiveWorkbook.Colors (Trying to store value based on data in cells

    Just playing around (more learning)

    I wrote this simple macro

    Sub Button1_Click()
        Dim ColorValue As String
    
        ColorValue = "RGB(" & Worksheets("Options").Range("H18").Value & ")"
    
    
            If ActiveCell = Worksheets("Options").Range("F3") Then
            ActiveWorkbook.Colors(1) = ColorValue
            MsgBox ColorValue
    Else
    End If
    End Sub
    I put the MsgBox to make sure the code for the variable ColorValue was right and it is indeed returning a RGB(#, #, #)
    However the color is not being set. Does it have to do with variable types (String, etc) ?

    All this does is allow the user to enter an RGB value in H18 like 255,255,0 and it should look at the active cell, in this case F3 (F3 has a value of 1) so it would try to set the RGB value to the colors(1)

    If I just use ActiveWorkbook.COlors(1) = RGB (255,255,255) in the macro, that does work..it's just this line that doesn't appear to be working

    ActiveWorkbook.Colors(1) = ColorValue

    I've tried two days of googling and messing with it and I can't figure out why it won't work. It doesn't throw errors, it just doesn't set the color value like it should. Thanks in advance.


    The only thing I can think of is that maybe its sending the quotes with ColorValue so it's putting in "RGB (#, #, #)" instead of without the quotes? if so..how to correct?
    Last edited by NewYears1978; 02-25-2015 at 12:28 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] store cells based on color
    By shart2k12 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-14-2013, 03:34 PM
  2. Store data into an array if/based on specific conditions met
    By exlgh91 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-21-2013, 11:38 AM
  3. Changing colors of cells based on other cells
    By Squatty in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-17-2011, 03:09 PM
  4. Fill cells with different colors based on different cell contents
    By mdeibel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-25-2010, 10:09 AM
  5. Is it possible to change colors of cells based on value in cell (.
    By LC in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-14-2005, 02:06 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