Bold Cell When Choose, UnBold When Choose Again

03856me

Active Member
Joined
Apr 4, 2008
Messages
297
I have a list of 30 items in column A on a simple worksheet, when a user chooses any or many of the items by clicking their mouse directly on the item, I would like the item to turn a different color or bold. Then I would like to write a formula in column B that would calculate the value of only those items selected. Is this possible? Should build a UserForm or simply have this in a spreadsheet?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
How about something like this to get you started?
Assuming your values are in A1:A30, this in the worksheet module should help.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("A1:A30")) Is Nothing Then Exit Sub
With Selection
  .Font.Bold = Not .Font.Bold
End With

MsgBox Application.WorksheetFunction.Sum(Range(Selection.Address))

End Sub

Hope it helps.
 
Upvote 0
D'oh - I've been doing this whilst watching the telly!
Code:
Option Explicit
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 
  Dim uRange As Range
  Dim oC As Range
  Dim BoldOn As Range
  Dim BoldOff As Range
 
  Set uRange = Range("A1:A30")
  Set BoldOn = Range("B1")
  Set BoldOff = Range("B2")
 
  If Intersect(Target, uRange) Is Nothing Then Exit Sub
 
  For Each oC In Intersect(Target, uRange)
    oC.Font.Bold = Not oC.Font.Bold
    oC.Font.Color = vbBlack + vbRed - oC.Font.Color
  Next oC
 
  Range("B1") = 0
  Range("B2") = 0
  For Each oC In uRange
    If oC.Font.Bold = True Then
      Range("B1") = Range("B1") + 1
    Else
      Range("B2") = Range("B2") + 1
    End If
  Next oC
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,977
Messages
6,175,753
Members
452,667
Latest member
vanessavalentino83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top