+ Reply to Thread
Results 1 to 4 of 4

Thread: How to create a macro to change the text color as i advance

  1. #1
    Registered User
    Join Date
    11-06-2008
    Location
    st. louis
    Posts
    2

    Exclamation How to create a macro to change the text color as i advance

    I manage a list for sales reps. they are on a rotation and i track who is next by changing the text color in my excel sheet. i also track the number of leads that they receive.

    right now i have two macros that only change the color of the text (one for red, one for black) and i'd like to use one macro that would advance through the list and change the current cell to red, while changing the previous one back to black.
    *it would also be awesome if it could also add +1 to the current count*
    ex.
    2 2
    2 2
    4 5
    6 6

    Any help is always appreciated

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979
    Hello tarnold,

    Welcome to the Forum!

    Do you want the macro to change the active cell's font color to red and then back to black when the next cell is selected? Will this happen only to certain cells, say only in one column or only to particular group of cells?

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    11-06-2008
    Location
    st. louis
    Posts
    2
    Hi Leith,

    Yes, it would be nice to change the active cell to red, then to black once i advance.

    Also, it would only be to certain cells within one column (columns are broken down by day of week, so i'm only in one column for that day)

    Any advice?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979
    Hello tarnold,

    This macro will change a single cell's font to red when selected and back to black when the next cell is selected. This will apply to the entire worksheet. If this similar to what you want to do, we can refine it for only certain cell ranges.
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
      Static PrevCell As Range
      
        If Target.Count > 1 Then Exit Sub
        If PrevCell Is Nothing Then Set PrevCell = Target
          
          PrevCell.Characters.Font.ColorIndex = xlColorAutomatic
          Target.Characters.Font.ColorIndex = 3    'Red
          
          Set PrevCell = Target
          
    End Sub
    How to Save a Worksheet Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
    3. Left Click on View Code in the pop up menu.
    4. Paste the macro code using CTRL+V
    5. Make any custom changes to the macro if needed at this time.
    6. Save the macro in your Workbook using CTRL+S

    Sincerely,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0