PC Review


Reply
Thread Tools Rate Thread

Bolding a Cell under certain conditions

 
 
DennyP
Guest
Posts: n/a
 
      25th Sep 2008
I am looking for a program/function that takes in a selected column,
and bolds any cell in that column where the cell above or the cell
below has the same value.

The worksheet is already sorted on the selected column.

Thanks for any pointers or suggestions for Excel 2007.
 
Reply With Quote
 
 
 
 
RyanH
Guest
Posts: n/a
 
      25th Sep 2008
This code will scan Col.A and bold any cell that has same value above and
below it. You will have to change it to which ever Column you need.

Option Explicit

Sub BoldCells()

Dim i As Long

For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row
If Cells(i - 1, "A").Value = Cells(i + 1, "A").Value Then
Cells(i, "A").Font.Bold = True
End If
Next i

End Sub

Hope this helps! If so, click "YES" below.
--
Cheers,
Ryan


"DennyP" wrote:

> I am looking for a program/function that takes in a selected column,
> and bolds any cell in that column where the cell above or the cell
> below has the same value.
>
> The worksheet is already sorted on the selected column.
>
> Thanks for any pointers or suggestions for Excel 2007.
>

 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      25th Sep 2008
On Wed, 24 Sep 2008 16:32:06 -0700 (PDT), DennyP <(E-Mail Removed)> wrote:

>I am looking for a program/function that takes in a selected column,
>and bolds any cell in that column where the cell above or the cell
>below has the same value.
>
>The worksheet is already sorted on the selected column.
>
>Thanks for any pointers or suggestions for Excel 2007.


Use conditional formatting (on the Home tab)

To apply this to C2:C10000

"Use a formula to determine which cells to format"

=OR(OFFSET(C2,-1,0)=C2,OFFSET(C2,1,0)=C2)

Then, in the CF Rules Manager, ensure the format applies to

=$C$2:$C$10000

--ron
 
Reply With Quote
 
DennyP
Guest
Posts: n/a
 
      25th Sep 2008

Thanks for the suggestions. I really appreciate it and I've learned a
lot from them.

 
Reply With Quote
 
DennyP
Guest
Posts: n/a
 
      25th Sep 2008
I made a slight change because I needed the bold to occur if the row
above or below was the same.

Sub BoldCells()
Dim i As Long
For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row
If (Cells(i - 1, "A").Value = Cells(i, "A").Value) Or (Cells(i
+ 1, "A").Value = Cells(i, "A").Value) Then
Cells(i, "A").Font.Bold = True
End If
Next i
End Sub

On Sep 24, 7:01*pm, RyanH <Ry...@discussions.microsoft.com> wrote:
> This code will scan Col.A and bold any cell that has same value above and
> below it. *You will have to change it to which ever Column you need.
>
> Option Explicit
>
> Sub BoldCells()
>
> Dim i As Long
>
> * * For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row
> * * * * If Cells(i - 1, "A").Value = Cells(i + 1, "A").Value Then
> * * * * * * Cells(i, "A").Font.Bold = True
> * * * * End If
> * * Next i
>
> End Sub
>
> Hope this helps! *If so, click "YES" below.
> --
> Cheers,
> Ryan
>
> "DennyP" wrote:
> > I am looking for a program/function that takes in a selected column,
> > and bolds any cell in that column where the cell above or the cell
> > below has the same value.

>
> > The worksheet is already sorted on the selected column.

>
> > Thanks for any pointers or suggestions for Excel 2007.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Countif Conditions - Use of conditions that vary by cell value JonTarg Microsoft Excel Misc 1 30th May 2008 01:21 PM
Bolding variable cell =?Utf-8?B?Sk9VSU9VSQ==?= Microsoft Excel Programming 5 16th Sep 2006 08:33 PM
Bolding Specific Cell Formula Question =?Utf-8?B?Ym9kaGlzYXR2YW9mYm9vZ2ll?= Microsoft Excel Misc 1 19th May 2006 03:06 PM
Macro for Bolding a Cell John Microsoft Excel Worksheet Functions 3 12th Nov 2003 10:28 PM
Question on cell borders unexpectedly bolding Arlene Microsoft Excel Misc 0 23rd Sep 2003 04:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:01 PM.