Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Bolding Subtotals

Excel 2003:
I was wondering if there is a way to write a macro that would bold any
subtotal on a worksheet. What I was thinking of doing is have some sort of
Do/Loop macro with a LEFT function where if Left(ActiveCell.Text, 9) =
"=SUBTOTAL" then bold the cell. It would then search all cells in the
worksheet with that condition and would look until, say, the activerow is
blank (or a better cutoff if you can think of one). I work with a lot of
reports and there are some who would like to use this macro, and I am the
only one who would know how to run it and where to install it to make it
available to others. Thanks.
--
Please rate posts so we know when we have answered your questions. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Bolding Subtotals

Use conditional formatting with a formula to look for Total

=ISNUMBER(SEARCH("total",A2))

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Orion Cochrane" wrote in message
...
Excel 2003:
I was wondering if there is a way to write a macro that would bold any
subtotal on a worksheet. What I was thinking of doing is have some sort of
Do/Loop macro with a LEFT function where if Left(ActiveCell.Text, 9) =
"=SUBTOTAL" then bold the cell. It would then search all cells in the
worksheet with that condition and would look until, say, the activerow is
blank (or a better cutoff if you can think of one). I work with a lot of
reports and there are some who would like to use this macro, and I am the
only one who would know how to run it and where to install it to make it
available to others. Thanks.
--
Please rate posts so we know when we have answered your questions. Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Bolding Subtotals

Onion,

You would want to search the formula string, not the text

Sub Macro1()

Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
End If
Next myC
End Sub


HTH,
Bernie
MS Excel MVP


"Orion Cochrane" wrote in message
...
Excel 2003:
I was wondering if there is a way to write a macro that would bold any
subtotal on a worksheet. What I was thinking of doing is have some sort of
Do/Loop macro with a LEFT function where if Left(ActiveCell.Text, 9) =
"=SUBTOTAL" then bold the cell. It would then search all cells in the
worksheet with that condition and would look until, say, the activerow is
blank (or a better cutoff if you can think of one). I work with a lot of
reports and there are some who would like to use this macro, and I am the
only one who would know how to run it and where to install it to make it
available to others. Thanks.
--
Please rate posts so we know when we have answered your questions. Thanks.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Bolding Subtotals

Thanks, Bernie. Your macro worked like a charm!
BTW, my name is Orion, not Onion. Don't worry. When I write my name, my "r"
looks like an "n" and it reads as "Onion" anyways :)
--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

Onion,

You would want to search the formula string, not the text

Sub Macro1()

Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
End If
Next myC
End Sub


HTH,
Bernie
MS Excel MVP


"Orion Cochrane" wrote in message
...
Excel 2003:
I was wondering if there is a way to write a macro that would bold any
subtotal on a worksheet. What I was thinking of doing is have some sort of
Do/Loop macro with a LEFT function where if Left(ActiveCell.Text, 9) =
"=SUBTOTAL" then bold the cell. It would then search all cells in the
worksheet with that condition and would look until, say, the activerow is
blank (or a better cutoff if you can think of one). I work with a lot of
reports and there are some who would like to use this macro, and I am the
only one who would know how to run it and where to install it to make it
available to others. Thanks.
--
Please rate posts so we know when we have answered your questions. Thanks.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Bolding Subtotals

O R ion,

I'm so sorry - my eyes aren't what they used to be ;-) staring too hard at code examples....

Bernie
MS Excel MVP


"Orion Cochrane" wrote in message
...
Thanks, Bernie. Your macro worked like a charm!
BTW, my name is Orion, not Onion. Don't worry. When I write my name, my "r"
looks like an "n" and it reads as "Onion" anyways :)
--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

Onion,

You would want to search the formula string, not the text

Sub Macro1()

Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
End If
Next myC
End Sub


HTH,
Bernie
MS Excel MVP


"Orion Cochrane" wrote in message
...
Excel 2003:
I was wondering if there is a way to write a macro that would bold any
subtotal on a worksheet. What I was thinking of doing is have some sort of
Do/Loop macro with a LEFT function where if Left(ActiveCell.Text, 9) =
"=SUBTOTAL" then bold the cell. It would then search all cells in the
worksheet with that condition and would look until, say, the activerow is
blank (or a better cutoff if you can think of one). I work with a lot of
reports and there are some who would like to use this macro, and I am the
only one who would know how to run it and where to install it to make it
available to others. Thanks.
--
Please rate posts so we know when we have answered your questions. Thanks.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Bolding Subtotals

I hear you! After working on the computer all day, I find it hard to read a
book or something. Thanks again Bernie! :)
--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

O R ion,

I'm so sorry - my eyes aren't what they used to be ;-) staring too hard at code examples....

Bernie
MS Excel MVP


"Orion Cochrane" wrote in message
...
Thanks, Bernie. Your macro worked like a charm!
BTW, my name is Orion, not Onion. Don't worry. When I write my name, my "r"
looks like an "n" and it reads as "Onion" anyways :)
--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

Onion,

You would want to search the formula string, not the text

Sub Macro1()

Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
End If
Next myC
End Sub


HTH,
Bernie
MS Excel MVP


"Orion Cochrane" wrote in message
...
Excel 2003:
I was wondering if there is a way to write a macro that would bold any
subtotal on a worksheet. What I was thinking of doing is have some sort of
Do/Loop macro with a LEFT function where if Left(ActiveCell.Text, 9) =
"=SUBTOTAL" then bold the cell. It would then search all cells in the
worksheet with that condition and would look until, say, the activerow is
blank (or a better cutoff if you can think of one). I work with a lot of
reports and there are some who would like to use this macro, and I am the
only one who would know how to run it and where to install it to make it
available to others. Thanks.
--
Please rate posts so we know when we have answered your questions. Thanks.






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Bolding Subtotals

I just realized I did not put a MsgBox to cancel the operation if no
subtotals were found. I tried putting an Else statement under the actions to
take if the condition was met with a MsgBox to display and the command Exit
Sub below the MsgBox, and it gave me the error "No cells were found." I gave
this macro to someone else, and I want to know where to put the MsgBox to
cancel the operation without the other person freaking out. Other than that,
the code you gave me works. Here's what I did:
Sub SubtotalBold
Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
Else
MsgBox [Msg]
Exit Sub
End If
Next myC
End Sub

--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

Onion,

You would want to search the formula string, not the text

Sub Macro1()

Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
End If
Next myC
End Sub


HTH,
Bernie
MS Excel MVP


"Orion Cochrane" wrote in message
...
Excel 2003:
I was wondering if there is a way to write a macro that would bold any
subtotal on a worksheet. What I was thinking of doing is have some sort of
Do/Loop macro with a LEFT function where if Left(ActiveCell.Text, 9) =
"=SUBTOTAL" then bold the cell. It would then search all cells in the
worksheet with that condition and would look until, say, the activerow is
blank (or a better cutoff if you can think of one). I work with a lot of
reports and there are some who would like to use this macro, and I am the
only one who would know how to run it and where to install it to make it
available to others. Thanks.
--
Please rate posts so we know when we have answered your questions. Thanks.




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Bolding Subtotals

Orion,

Sub Macro2()

Dim myC As Range
Dim boolFound As Boolean

boolFound = False

On Error Goto NoFormulas
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
boolFound = True
End If
Next myC
If boolFound Then Exit Sub
Msgbox "No SubTotal Formulas found"
NoFormulas:
End Sub

BErnie

"Orion Cochrane" wrote in message
...
I just realized I did not put a MsgBox to cancel the operation if no
subtotals were found. I tried putting an Else statement under the actions
to
take if the condition was met with a MsgBox to display and the command
Exit
Sub below the MsgBox, and it gave me the error "No cells were found." I
gave
this macro to someone else, and I want to know where to put the MsgBox to
cancel the operation without the other person freaking out. Other than
that,
the code you gave me works. Here's what I did:
Sub SubtotalBold
Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
Else
MsgBox [Msg]
Exit Sub
End If
Next myC
End Sub

--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

Onion,

You would want to search the formula string, not the text

Sub Macro1()

Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
End If
Next myC
End Sub


HTH,
Bernie
MS Excel MVP


"Orion Cochrane" wrote in
message
...
Excel 2003:
I was wondering if there is a way to write a macro that would bold any
subtotal on a worksheet. What I was thinking of doing is have some sort
of
Do/Loop macro with a LEFT function where if Left(ActiveCell.Text, 9) =
"=SUBTOTAL" then bold the cell. It would then search all cells in the
worksheet with that condition and would look until, say, the activerow
is
blank (or a better cutoff if you can think of one). I work with a lot
of
reports and there are some who would like to use this macro, and I am
the
only one who would know how to run it and where to install it to make
it
available to others. Thanks.
--
Please rate posts so we know when we have answered your questions.
Thanks.






  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Bolding Subtotals

I tried that, and I get the error msgbox that you wrote when I execute the
macro when subtotals are present as well. Should the If boolFound lines be on
the top after declaring my variables? I want the macro to check for subtotals
first and, if none are found, to Exit Sub like you did. Other than that, I do
not get a debug dialog box if there are no subtotals present.
--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

Orion,

Sub Macro2()

Dim myC As Range
Dim boolFound As Boolean

boolFound = False

On Error Goto NoFormulas
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
boolFound = True
End If
Next myC
If boolFound Then Exit Sub
Msgbox "No SubTotal Formulas found"
NoFormulas:
End Sub

BErnie

"Orion Cochrane" wrote in message
...
I just realized I did not put a MsgBox to cancel the operation if no
subtotals were found. I tried putting an Else statement under the actions
to
take if the condition was met with a MsgBox to display and the command
Exit
Sub below the MsgBox, and it gave me the error "No cells were found." I
gave
this macro to someone else, and I want to know where to put the MsgBox to
cancel the operation without the other person freaking out. Other than
that,
the code you gave me works. Here's what I did:
Sub SubtotalBold
Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
Else
MsgBox [Msg]
Exit Sub
End If
Next myC
End Sub

--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

Onion,

You would want to search the formula string, not the text

Sub Macro1()

Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
End If
Next myC
End Sub


HTH,
Bernie
MS Excel MVP


"Orion Cochrane" wrote in
message
...
Excel 2003:
I was wondering if there is a way to write a macro that would bold any
subtotal on a worksheet. What I was thinking of doing is have some sort
of
Do/Loop macro with a LEFT function where if Left(ActiveCell.Text, 9) =
"=SUBTOTAL" then bold the cell. It would then search all cells in the
worksheet with that condition and would look until, say, the activerow
is
blank (or a better cutoff if you can think of one). I work with a lot
of
reports and there are some who would like to use this macro, and I am
the
only one who would know how to run it and where to install it to make
it
available to others. Thanks.
--
Please rate posts so we know when we have answered your questions.
Thanks.






  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Bolding Subtotals

You should not get the msgbox when SUBTOTAL formulas are present. But you can try this, which
covers all three cases: No formulas of any kind, formulas but no SUBTOTAL formulas, and some
SUBTOTAL formulas.


HTH,
Bernie
MS Excel MVP

Sub NewMacro()
Dim myC As Range
Dim boolFound As Boolean

boolFound = False

On Error GoTo NoFormulas
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
boolFound = True
End If
Next myC
If boolFound Then
MsgBox "SubTotal Formulas were found and bolded"
Else
MsgBox "No SubTotal Formulas found"
End If

Exit Sub

NoFormulas:
MsgBox "No Formulas of any kind found"

End Sub


"Orion Cochrane" wrote in message
...
I tried that, and I get the error msgbox that you wrote when I execute the
macro when subtotals are present as well. Should the If boolFound lines be on
the top after declaring my variables? I want the macro to check for subtotals
first and, if none are found, to Exit Sub like you did. Other than that, I do
not get a debug dialog box if there are no subtotals present.
--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

Orion,

Sub Macro2()

Dim myC As Range
Dim boolFound As Boolean

boolFound = False

On Error Goto NoFormulas
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
boolFound = True
End If
Next myC
If boolFound Then Exit Sub
Msgbox "No SubTotal Formulas found"
NoFormulas:
End Sub

BErnie

"Orion Cochrane" wrote in message
...
I just realized I did not put a MsgBox to cancel the operation if no
subtotals were found. I tried putting an Else statement under the actions
to
take if the condition was met with a MsgBox to display and the command
Exit
Sub below the MsgBox, and it gave me the error "No cells were found." I
gave
this macro to someone else, and I want to know where to put the MsgBox to
cancel the operation without the other person freaking out. Other than
that,
the code you gave me works. Here's what I did:
Sub SubtotalBold
Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
Else
MsgBox [Msg]
Exit Sub
End If
Next myC
End Sub

--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

Onion,

You would want to search the formula string, not the text

Sub Macro1()

Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
End If
Next myC
End Sub


HTH,
Bernie
MS Excel MVP


"Orion Cochrane" wrote in
message
...
Excel 2003:
I was wondering if there is a way to write a macro that would bold any
subtotal on a worksheet. What I was thinking of doing is have some sort
of
Do/Loop macro with a LEFT function where if Left(ActiveCell.Text, 9) =
"=SUBTOTAL" then bold the cell. It would then search all cells in the
worksheet with that condition and would look until, say, the activerow
is
blank (or a better cutoff if you can think of one). I work with a lot
of
reports and there are some who would like to use this macro, and I am
the
only one who would know how to run it and where to install it to make
it
available to others. Thanks.
--
Please rate posts so we know when we have answered your questions.
Thanks.










  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Bolding Subtotals

Thanks, Bernie! It works. I realized after why you put the Exit Sub line
after the End If for the MsgBoxes and just above the NoFormulas. It works
great now. I tested it under all 3 conditions (Subtotals, No Subtotals, No
Formulas) and the appropriate actions took place. Again, you are a lifesaver
for not just me, but others who will have this macro as well.
--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

You should not get the msgbox when SUBTOTAL formulas are present. But you can try this, which
covers all three cases: No formulas of any kind, formulas but no SUBTOTAL formulas, and some
SUBTOTAL formulas.


HTH,
Bernie
MS Excel MVP

Sub NewMacro()
Dim myC As Range
Dim boolFound As Boolean

boolFound = False

On Error GoTo NoFormulas
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
boolFound = True
End If
Next myC
If boolFound Then
MsgBox "SubTotal Formulas were found and bolded"
Else
MsgBox "No SubTotal Formulas found"
End If

Exit Sub

NoFormulas:
MsgBox "No Formulas of any kind found"

End Sub


"Orion Cochrane" wrote in message
...
I tried that, and I get the error msgbox that you wrote when I execute the
macro when subtotals are present as well. Should the If boolFound lines be on
the top after declaring my variables? I want the macro to check for subtotals
first and, if none are found, to Exit Sub like you did. Other than that, I do
not get a debug dialog box if there are no subtotals present.
--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

Orion,

Sub Macro2()

Dim myC As Range
Dim boolFound As Boolean

boolFound = False

On Error Goto NoFormulas
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
boolFound = True
End If
Next myC
If boolFound Then Exit Sub
Msgbox "No SubTotal Formulas found"
NoFormulas:
End Sub

BErnie

"Orion Cochrane" wrote in message
...
I just realized I did not put a MsgBox to cancel the operation if no
subtotals were found. I tried putting an Else statement under the actions
to
take if the condition was met with a MsgBox to display and the command
Exit
Sub below the MsgBox, and it gave me the error "No cells were found." I
gave
this macro to someone else, and I want to know where to put the MsgBox to
cancel the operation without the other person freaking out. Other than
that,
the code you gave me works. Here's what I did:
Sub SubtotalBold
Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
Else
MsgBox [Msg]
Exit Sub
End If
Next myC
End Sub

--
Please rate posts so we know when we have answered your questions. Thanks.


"Bernie Deitrick" wrote:

Onion,

You would want to search the formula string, not the text

Sub Macro1()

Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") 0 Then
myC.Font.Bold = True
End If
Next myC
End Sub


HTH,
Bernie
MS Excel MVP


"Orion Cochrane" wrote in
message
...
Excel 2003:
I was wondering if there is a way to write a macro that would bold any
subtotal on a worksheet. What I was thinking of doing is have some sort
of
Do/Loop macro with a LEFT function where if Left(ActiveCell.Text, 9) =
"=SUBTOTAL" then bold the cell. It would then search all cells in the
worksheet with that condition and would look until, say, the activerow
is
blank (or a better cutoff if you can think of one). I work with a lot
of
reports and there are some who would like to use this macro, and I am
the
only one who would know how to run it and where to install it to make
it
available to others. Thanks.
--
Please rate posts so we know when we have answered your questions.
Thanks.









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bolding using VBA Brad Excel Programming 7 March 6th 08 02:33 PM
Bolding Row from VB6 Ian B[_2_] Excel Programming 4 July 9th 05 11:19 PM
Bolding when subtotalling mrsteve1 Excel Worksheet Functions 2 February 17th 05 11:26 PM
Bolding Dale[_12_] Excel Programming 2 September 30th 04 04:21 PM
Bolding problem on Subtotals CLR Excel Programming 2 September 19th 04 07:00 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"