Full Version: bold if value changes
UtterAccess Discussion Forums > Microsoft® Office > Microsoft Excel
bakersburg9
I am working with a spreadsheet where I'm updating values, and want the font set to bold when/if the value in a cell changes. I may have used the code shown below from Crystal a few months back, but forgot how to apply it. Any ideas how to use this code ? It's not working for me, and I can't find what I'm doing wrong - I searched UA for samples of the Worsheet_Change event coding, but found nothing.

Sub BoldWhenDifferent()

Dim mCol As Long _
, mRow As Long _
, mValue

mCol = ActiveCell.Column

'first value is bolded
ActiveCell.Font.Bold = True
mValue = ActiveCell

'assumes you are in the first row of data
For mRow = ActiveCell.Row To ActiveSheet.UsedRange.Rows.Count
If Not IsError(Cells(mRow, mCol)) Then
If Cells(mRow, mCol) <> mValue Then Cells(mRow, mCol).Font.Bold = True
mValue = Cells(mRow, mCol)
End If
Next mRow

End Sub
KingMartin
Hi Steve,

not sure what you are after, this sounds rather like a task for conditional format.

This will change any cell in ANY sheet you change to bold, if you really must:

CODE
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Target.Font.Bold = True
End Sub


The code goes into ThisWorkbook module.

Martin
bakersburg9
Martin,
Thanks!
Steve
bakersburg9
Martin,
That is a really slick piece of code - talk about a small block of code - I know a lot of people might never need something like that, but this will come in handy - thanks again cool.gif
Steve
KingMartin
You're welcome cool.gif

Martin
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.