UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> bold if value changes    
 
   
bakersburg9
post May 1 2007, 01:22 PM
Post #1

UtterAccess Ruler
Posts: 4,254
From: Downey, CA



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
Go to the top of the page
 
+
KingMartin
post May 1 2007, 02:51 PM
Post #2

Retired Moderator
Posts: 10,959
From: Prague,CZ / Kiev,UA



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
Go to the top of the page
 
+
bakersburg9
post May 1 2007, 03:46 PM
Post #3

UtterAccess Ruler
Posts: 4,254
From: Downey, CA



Martin,
Thanks!
Steve
Go to the top of the page
 
+
bakersburg9
post May 1 2007, 04:26 PM
Post #4

UtterAccess Ruler
Posts: 4,254
From: Downey, CA



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 (IMG:http://www.utteraccess.com/forum/style_emoticons/default/cool.gif)
Steve
Go to the top of the page
 
+
KingMartin
post May 2 2007, 01:03 AM
Post #5

Retired Moderator
Posts: 10,959
From: Prague,CZ / Kiev,UA



You're welcome (IMG:http://www.utteraccess.com/forum/style_emoticons/default/cool.gif)

Martin
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 12:40 AM