#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Automate Macro

I searched this forum and found the function
=SUMPRODUCT(--(boldrange(G$4:G$19))) will count bolded words in a range of
cells. The macro it calls is at the bottom of this message.

My problem is whenever I bold or unbold a word in one of these cells the
function doesn't update unless I click in the function and hit enter. How do
I automate it to keep updating the count as I bold or unbold words?

I've been reading articles at http://www.cpearson.com/excel/Events.aspx but
must say it's a little over my head.

Oh and it may be helfpul to know that I have many sheets so I want to apply
it to the entire workbook.

Thanks for the help.

Function BoldRange(rng As Range) As Variant
'---------------------------------------------------------------------
Dim cell As Range, row As Range
Dim i As Long, j As Long
Dim iWhite As Long, iBlack As Long
Dim aryBold As Variant
If rng.Areas.Count 1 Then
BoldRange = CVErr(xlErrValue)
Exit Function
End If
If rng.Cells.Count = 1 Then
Set BoldRange = rng
Else
aryBold = rng.Value
i = 0
For Each row In rng.Rows
i = i + 1
j = 0
For Each cell In row.Cells
j = j + 1
aryBold(i, j) = cell.Font.Bold
Next cell
Next row
End If
BoldRange = aryBold
End Function
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Automate Macro

Changing the format of a cell doesn't tell excel that it's time to recalculate.

You could make it so that your function will recalc each time excel recalcs by
adding a line to your function:


Function BoldRange(rng As Range) As Variant
application.volatile
'---------------------------------------------------------------------
Dim cell As Range, row As Range
....

But this still means that you could be one calculation behind. I wouldn't trust
the output until I forced a recalc (F9 or Shift-F9 or Ctrl-Alt-F9 or
Ctrl-Shift-Alt-F9)

See excel's help for the differences.


jenniferspnc wrote:

I searched this forum and found the function
=SUMPRODUCT(--(boldrange(G$4:G$19))) will count bolded words in a range of
cells. The macro it calls is at the bottom of this message.

My problem is whenever I bold or unbold a word in one of these cells the
function doesn't update unless I click in the function and hit enter. How do
I automate it to keep updating the count as I bold or unbold words?

I've been reading articles at http://www.cpearson.com/excel/Events.aspx but
must say it's a little over my head.

Oh and it may be helfpul to know that I have many sheets so I want to apply
it to the entire workbook.

Thanks for the help.

Function BoldRange(rng As Range) As Variant
'---------------------------------------------------------------------
Dim cell As Range, row As Range
Dim i As Long, j As Long
Dim iWhite As Long, iBlack As Long
Dim aryBold As Variant
If rng.Areas.Count 1 Then
BoldRange = CVErr(xlErrValue)
Exit Function
End If
If rng.Cells.Count = 1 Then
Set BoldRange = rng
Else
aryBold = rng.Value
i = 0
For Each row In rng.Rows
i = i + 1
j = 0
For Each cell In row.Cells
j = j + 1
aryBold(i, j) = cell.Font.Bold
Next cell
Next row
End If
BoldRange = aryBold
End Function


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default Automate Macro

Basically you don't. Bolding/unbolding does not trigger a recalculation. You
could add Application Volatile to the UDF, but that will only force it to
update when something triggers a recalculation, it still won't trigger it
itself.

--
__________________________________
HTH

Bob

"jenniferspnc" wrote in message
...
I searched this forum and found the function
=SUMPRODUCT(--(boldrange(G$4:G$19))) will count bolded words in a range of
cells. The macro it calls is at the bottom of this message.

My problem is whenever I bold or unbold a word in one of these cells the
function doesn't update unless I click in the function and hit enter. How
do
I automate it to keep updating the count as I bold or unbold words?

I've been reading articles at http://www.cpearson.com/excel/Events.aspx
but
must say it's a little over my head.

Oh and it may be helfpul to know that I have many sheets so I want to
apply
it to the entire workbook.

Thanks for the help.

Function BoldRange(rng As Range) As Variant
'---------------------------------------------------------------------
Dim cell As Range, row As Range
Dim i As Long, j As Long
Dim iWhite As Long, iBlack As Long
Dim aryBold As Variant
If rng.Areas.Count 1 Then
BoldRange = CVErr(xlErrValue)
Exit Function
End If
If rng.Cells.Count = 1 Then
Set BoldRange = rng
Else
aryBold = rng.Value
i = 0
For Each row In rng.Rows
i = i + 1
j = 0
For Each cell In row.Cells
j = j + 1
aryBold(i, j) = cell.Font.Bold
Next cell
Next row
End If
BoldRange = aryBold
End Function



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
Macro to automate process Journey Excel Discussion (Misc queries) 0 June 13th 08 03:53 PM
Automate Macro Sherry Excel Discussion (Misc queries) 4 May 16th 08 07:18 PM
Macro to Automate Saving Rich Excel Discussion (Misc queries) 5 May 19th 06 10:26 AM
Automate Macro Chiku Excel Discussion (Misc queries) 0 December 15th 05 01:25 AM
Automate Macro Chiku Excel Discussion (Misc queries) 0 December 15th 05 01:25 AM


All times are GMT +1. The time now is 09:15 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"