ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If ActiveCell.Font.Bold = True Then ... trying to specify a range, not 'entirerow' (https://www.excelbanter.com/excel-programming/360142-if-activecell-font-bold-%3D-true-then-trying-specify-range-not-entirerow.html)

Winawer

If ActiveCell.Font.Bold = True Then ... trying to specify a range, not 'entirerow'
 

Hi. Am new to Excel, having a problem, seems like it's something
trivial.

I need it to check a given cell, and if that cell is bold, then for it
to bold _a_range_ of cells (ie not just one, nor the entire row).

For a single cell (say the one next to it) I would just put
If ActiveCell.Font.Bold = True Then
ActiveCell.Offset(0, 1).Font.Bold = True

And for the entire row:
If ActiveCell.Font.Bold = True Then
ActiveCell.EntireRow.Font.Bold = True

but how do I specify a given range? (say A1 is the cell for checking
and B1:B100 the range to be bolded if necessary). I should add this is
part of a loop (ie there are, say, 50 rows to be checked).

Many thanks for any help


--
Winawer
------------------------------------------------------------------------
Winawer's Profile: http://www.excelforum.com/member.php...o&userid=33978
View this thread: http://www.excelforum.com/showthread...hreadid=537509


macropod

If ActiveCell.Font.Bold = True Then ... trying to specify a range, not 'entirerow'
 
Hi Winwaver,

To make a range of cells bold, offset from the active cell, you could use
something like:
If ActiveCell.Font.Bold = True Then _
Range(ActiveCell.Offset(0, 1), ActiveCell.Offset(1, 0)).Font.Bold = True

For a defined range (eg B1:B100), this becomes:
If ActiveCell.Font.Bold = True Then _
Range("B1","B100").Font.Bold = True

Cheers


"Winawer" wrote in
message ...

Hi. Am new to Excel, having a problem, seems like it's something
trivial.

I need it to check a given cell, and if that cell is bold, then for it
to bold _a_range_ of cells (ie not just one, nor the entire row).

For a single cell (say the one next to it) I would just put
If ActiveCell.Font.Bold = True Then
ActiveCell.Offset(0, 1).Font.Bold = True

And for the entire row:
If ActiveCell.Font.Bold = True Then
ActiveCell.EntireRow.Font.Bold = True

but how do I specify a given range? (say A1 is the cell for checking
and B1:B100 the range to be bolded if necessary). I should add this is
part of a loop (ie there are, say, 50 rows to be checked).

Many thanks for any help


--
Winawer
------------------------------------------------------------------------
Winawer's Profile:

http://www.excelforum.com/member.php...o&userid=33978
View this thread: http://www.excelforum.com/showthread...hreadid=537509




Winawer[_2_]

If ActiveCell.Font.Bold = True Then ... trying to specify a range, not 'entirerow'
 

Many thanks for the reply.

I should have made it clearer that it's within a loop of say, 50 rows.
Specifying the exact range like above works for the first row, but then
when it checks the second row it doesn't work. I think I maybe need to
offset the specific range in some way, but I'm not sure how to do this.
Is there a way to specify the cells so that it works for each row in
about 50 rows?


--
Winawer
------------------------------------------------------------------------
Winawer's Profile: http://www.excelforum.com/member.php...o&userid=33978
View this thread: http://www.excelforum.com/showthread...hreadid=537509


Winawer[_3_]

If ActiveCell.Font.Bold = True Then ... trying to specify a range, not 'entirerow'
 

Ignore my last post. I re-read macropod's reply and have got it working.


--
Winawer
------------------------------------------------------------------------
Winawer's Profile: http://www.excelforum.com/member.php...o&userid=33978
View this thread: http://www.excelforum.com/showthread...hreadid=537509



All times are GMT +1. The time now is 12:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com