Macro to Bold Font & Place Border around selected cell.....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deve8ore
    New Member
    • Apr 2008
    • 34

    Macro to Bold Font & Place Border around selected cell.....

    Hello, I have a basic Excel worksheet that allows users to select:

    Yes No Maybe

    .... and checkboxes to the right. They unfortunately are complaining that the checkboxes are too small, and I cannot make the boxes larger, so...........

    Can someone assist in the macro where they can just click on the cell where "Yes" appears, and it will bold and be outlined, and if they click on that same cell again it will go back to normal (No bold and not outlined)?

    Of course same would apply for the "No", and the "Maybe".

    I'm hoping this is fairly basic. If not, other suggestions? Button to the right of the "Yes", "No", "Maybe", where if the button is selected the "Yes" (ect... ) will format accordingly?

    Thank you.
    Last edited by deve8ore; Jun 18 '08, 09:32 PM. Reason: Format
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    sure, inside the worksheet's code, check the SelectionChange event:

    [CODE=vb]Private Sub Worksheet_Selec tionChange(ByVa l Target As Range)
    Cells.Font.Bold = False
    Target.Font.Bol d = True
    End Sub[/CODE]

    i think that's a good start, aint it?

    (^.^ i've just noticed this code is quite fun to play with)

    you can also check this howto (im sure you'll find it useful):
    Last edited by kadghar; Jun 18 '08, 10:04 PM. Reason: adding a comment

    Comment

    • deve8ore
      New Member
      • Apr 2008
      • 34

      #3
      That is a good start... thanks!

      Only thing is that when I click on "Yes", it will bold, however when i click on another cell it will unbold.

      I'd like the users to select "Yes" (or "No, ect..) and have it remain bold, then move on to the next question and select Y,N, and have it bold and stay bold, unless they click on it again and it will unbold.

      Since we're this far, how would I go about placing a border around it, changing the background / font color.

      Thanks again for your help, it is appreciated!

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        Try this :

        [code=vb]
        Range("A4").Sel ect
        Selection.Borde rs(xlEdgeLeft). LineStyle = xlContinuous
        Selection.Borde rs(xlEdgeTop).L ineStyle = xlContinuous
        Selection.Borde rs(xlEdgeBottom ).LineStyle = xlContinuous
        Selection.Borde rs(xlEdgeRight) .LineStyle = xlContinuous
        Selection.Font. ColorIndex = 40
        With Selection.Inter ior
        .ColorIndex = 5
        .Pattern = xlSolid
        End With
        [/code]

        Regards
        Veena

        Comment

        • kadghar
          Recognized Expert Top Contributor
          • Apr 2007
          • 1302

          #5
          Originally posted by deve8ore
          That is a good start... thanks!

          Only thing is that when I click on "Yes", it will bold, however when i click on another cell it will unbold.

          I'd like the users to select "Yes" (or "No, ect..) and have it remain bold, then move on to the next question and select Y,N, and have it bold and stay bold, unless they click on it again and it will unbold.
          ...
          well. you'll just have to play a litle bit with som IF / THEN

          [CODE=vb]if target. column = 1 and target.row=1 then
          'bla bla bla
          else
          'bla bla bla
          'end if[/CODE]

          HTH

          Comment

          Working...