+ Reply to Thread
Results 1 to 23 of 23

Changing letter color automatically

  1. #1
    Registered User
    Join Date
    09-16-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    48

    Changing letter color automatically

    I want to change a letter color automatically when i type it. For example a = red; b = blue; c = yellow and so on..

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing letter color automatically

    Type where? In cell, you can't do that, as VBA code cannot run while you are in cell edit mode.

    However, it can be achieved after you confirm your entry in a cell. Note that this will bloat file size and may add overhead to workbook performance.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    09-16-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    48

    Re: Changing letter color automatically

    Yes, when i type a letter in a cell i want that it changes the color based on a legend.
    Vba runs after i type that letter, when i press enter the color changes..

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Changing letter color automatically

    Are you typing just one letter in the cell or are you typing many letters in the cell? If many, do you want to change all letters even if they are inside words?

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing letter color automatically

    Something like below. Code currently set to only apply when single cell value is changed in Column A of sheet where code is pasted in.

    Adjust and play with it as you need.
    Please Login or Register  to view this content.
    If it's single character cell only, just use CF or limit the code above by checking Len(Target.Value) = 1

  6. #6
    Registered User
    Join Date
    09-16-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    48

    Re: Changing letter color automatically

    Thank you, i will try now.

  7. #7
    Registered User
    Join Date
    09-16-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    48

    Re: Changing letter color automatically

    Not valid argument, run-time error '5'

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing letter color automatically

    At which line?

    Tested and works fine on my end.

    See attached. Cell's fill color changed to make font color more visible.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    09-16-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    48

    Re: Changing letter color automatically

    Hmm.. that's strange, let me attach an image.

    This is where the magic should happen : Attachment 641779

  10. #10
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing letter color automatically

    Invalid attachment. Try using "Go Advanced" and attach image.

    Or even better, upload sample workbook where you are receiving that error (or smaller sample where you can replicate the issue).

  11. #11
    Registered User
    Join Date
    09-16-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    48

    Re: Changing letter color automatically

    Maybe this could work : https://imgur.com/a/aHxkBKP

  12. #12
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing letter color automatically

    That doesn't help at all. Image tells me nothing of "how" you implemented the code. And which specific line in the code generated that error.

    Also, from image, it's near impossible to tell, the full scope requirement for the code.

  13. #13
    Registered User
    Join Date
    09-16-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    48

    Re: Changing letter color automatically

    I am gonna type only one letter per cell

  14. #14
    Registered User
    Join Date
    09-16-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    48

    Re: Changing letter color automatically

    The error is in this line :
    Please Login or Register  to view this content.
    I put the code in a function module, but there is no button that calls that function. So what element in the code calls that Sub to apply changes immediately?

  15. #15
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing letter color automatically

    It's not a function. It's a sub routine that should go in Worksheet module (of the sheet where you want to apply font color).

    And code is triggered on worksheet_Change event.

    Check by going to VBE in the sample I uploaded. You will see that it's in Sheet1 module.

  16. #16
    Registered User
    Join Date
    09-16-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    48

    Re: Changing letter color automatically

    Yes.. in fact i was naming the Sub with a casual name, then I realized that I had to put that specific name.. now no more errors but when i set my interval in the range parameters Range("WW:WW"), the color doesn't change.

  17. #17
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing letter color automatically

    Upload sample workbook. My guess, is that you don't have specific letters mapped out in Case statement.

    But without sample workbook, I'll be wasting time going back and forth, trying to guess what you are doing.

    To upload, use "Go Advanced" button, follow "Manage Attachments" hyperlink. It will launch new tab/window for managing uploads.

  18. #18
    Registered User
    Join Date
    09-16-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    48

    Re: Changing letter color automatically

    Sorry for that but my Manage Attachments button doesn't work.

  19. #19
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing letter color automatically

    Don't use the shortcut button. Use "Go Advanced" button. It will open up more interface, which has "Manage Attachments" hyperlink (not shortcut button).

    Shorcut button hasn't worked for a while now.

  20. #20
    Registered User
    Join Date
    09-16-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    48

    Re: Changing letter color automatically

    Okay here it is, try to put letter k in column WW
    Attached Files Attached Files

  21. #21
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Changing letter color automatically

    You uploaded ".xlsx" which doesn't support macro...

    So I've got no clue what your modified code looked like.

    Modifying my code a bit, works fine.
    Attached Files Attached Files

  22. #22
    Registered User
    Join Date
    09-16-2019
    Location
    Italy
    MS-Off Ver
    2016
    Posts
    48

    Re: Changing letter color automatically

    Oh thanks, you saved me.

  23. #23
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Changing letter color automatically

    Show us the exact code you tried to use that did not work for you.

+ 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. Replies: 3
    Last Post: 08-18-2014, 12:47 PM
  2. Caps letter automatically changing to small pls help.....
    By shiva125 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-21-2012, 03:20 AM
  3. Changing the color of the row automatically
    By paragkalra in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 05-30-2010, 10:42 PM
  4. Changing color of date cells automatically
    By CLSSY56 in forum Excel General
    Replies: 20
    Last Post: 04-30-2008, 01:07 PM
  5. Changing first letter to caps, letters after "-" and "/", and rest to small letter.
    By rhexis07 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-17-2008, 08:03 PM
  6. Changing cell background color automatically
    By PCMagician in forum Excel General
    Replies: 4
    Last Post: 03-11-2008, 12:58 PM
  7. [SOLVED] automatically changing the background color of a cell
    By martin in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-06-2005, 08:06 AM

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.6.0 RC 1