+ Reply to Thread
Results 1 to 9 of 9

Creating a cell in colour

Hybrid View

  1. #1
    Registered User
    Join Date
    04-20-2009
    Location
    leeds
    MS-Off Ver
    Excel 2003
    Posts
    4

    Creating a cell in colour

    good evening
    i have an excel sheet which i want to enter a number in cell say b25 and if the number shows on the sheet between cell c3 and h23 how is this done, all it is for is simple lottery sheet number 1-49 entered into b25 if some one hase the number say in c3 then it turns red? thanks in advance for any help

  2. #2
    Forum Contributor GuruWannaB's Avatar
    Join Date
    01-24-2008
    Location
    An hour due East of Cowtown Ohio
    MS-Off Ver
    2010
    Posts
    421

    Re: Creating a cell in colour

    Do you want C3 to turn red if its the number in b25? or do you want b25 to turn red if its in your c3:h23 range?
    Last edited by GuruWannaB; 04-20-2009 at 05:30 PM.

  3. #3
    Registered User
    Join Date
    04-20-2009
    Location
    leeds
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Creating a cell in colour

    yes if i enter number 14 in c25 and the number appears in lets say d12 f14 and e17 then i want those three to turn red. thanks for the speey responce

  4. #4
    Forum Contributor GuruWannaB's Avatar
    Join Date
    01-24-2008
    Location
    An hour due East of Cowtown Ohio
    MS-Off Ver
    2010
    Posts
    421

    Re: Creating a cell in colour

    Look at this...I used conditional formats and named ranges.

    Hope this helps,

    GWB
    Attached Files Attached Files
    Last edited by GuruWannaB; 04-20-2009 at 06:35 PM.

  5. #5
    Registered User
    Join Date
    04-20-2009
    Location
    leeds
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Creating a cell in colour

    thanks for that that was just the ticket, the only problem it does not save the numbers entered and stay red if you change the number ?

  6. #6
    Forum Contributor GuruWannaB's Avatar
    Join Date
    01-24-2008
    Location
    An hour due East of Cowtown Ohio
    MS-Off Ver
    2010
    Posts
    421

    Re: Creating a cell in colour

    I'm not the best with VBA...but I was able to write something that works.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    Dim numbers As Range
    Dim xvz As Integer
    
    Set numbers = Range("C3:h23")
    
    xvz = Range("b25").Value
        For Each cell In numbers
            If cell.Value = xvz Then
                With cell.Interior
                    .ColorIndex = 3
                    .Pattern = xlSolid
                End With
            End If
        Next cell
    End Sub
    I have this as a selection change event (Right click on the tab and select view code...paste it in there) I've also included the updated example sheet.
    Attached Files Attached Files
    I help because of the Pavlovian dog that resides in the inner me...so if you are happy with the results, please add to my reputation. It helps keep me motivated!



    Please mark your threads as Solved once it is solved. Check the FAQ's to see how.

+ 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