activecell hightlight with bold text : ok. with yellow borders: not ok: not restored to before

  • hello :)

    my selection change event changes the active cell to bold text that returns to normal text when clicked away.

    the same should happen for going from no borders to thick yellow borders:

    they appear, but after the next click they stay on the previous cell...

    what is my mistake ?

    have a great sunday !!!

  • hi Littlepete,

    There is no worksheet OnExit event but try

  • hello ;)

    i tried your code but the borders stay where they are... that is something i achieved already too... so far i use this,

    to make the text go bold and normal on next click:

    Static PrevCell As Range
    If Target.Cells.Count > 1 Then Exit Sub
    If Not PrevCell Is Nothing Then
    PrevCell.Font.Bold = False
    End If
    Target.Font.Bold = True
    Set PrevCell = Target

    i dont find a way to to add borders, i tried borderaround, and borders but they never disappear after the next click...

    thanks for your help :) !!!

  • I think I'm not wrong if I say that the selected cell border color simply cannot be adjusted since there is no such option in Excel. It will always have the color given by the theme of the operating system. You can see the border change color only after changing cell. I suggest focusing on the background color and bold font to highlight the activecell.

  • i found the solution :

  • why make an address list when they are all in my cell phone?

    why try all those vba things if i can just look them up?

    because i love to learn vba...

  • i noticed that, but it works for the putting text in bold. so i'm not changing anything, trying to add yellow borders...

    Was that a response to my question. If it doesn't have a value(i.e. a range) then it cannot affect your code so it's nonsense not to change it or remove it!

  • You will probably find that the selected cell does get a yellow border but that border is not visible while the cell is selected because excel has a black border to show the selected cell. Fill does work and show though.

    Attached is a file to do what you want, but with a yellow fill rather than a yellow border. The address of your previous selection is stored in Cell F1 which has the Defined Name "PrevADD" (you can use any cell on your sheet which is not being used and name it "PrevAdd", if you set the font colour of that cell to be the same as the cell fill colour then the text will not be visible).

    Bold font and yellow fill will be applied to any selected cell that is not empty, you can further refine the code to work only on particular columns or rows, or on a specified range.

    The code in the sheet Object Module is

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!