PC Review


Reply
Thread Tools Rate Thread

How can I count BOLD letters in a cell?

 
 
=?Utf-8?B?RHVkZGx5IER1bW15?=
Guest
Posts: n/a
 
      8th Apr 2007
I need to create 2 cells from one cell based on Bold Type. The Bold type
characters (name) will be copied into one new cell with the rest of the
characters (registration number, color(bay/chestnut) and dates) in a 2nd new
cell. The original cell can contain up to 28 alpha/numeric characters. How
can I count the number of Bold Type characters in a cell? I will be working
with several hundred original mixed cells.

EX:NAME ahr#1234567 1989 (with NAME being bold type.)

Thanks in advance for your help!!


 
Reply With Quote
 
 
 
 
JE McGimpsey
Guest
Posts: n/a
 
      8th Apr 2007
ONe wa:

Public Function BoldChars(ByRef rCell As Excel.Range) As Variant
Dim nCount As Long
Dim i As Long
With rCell
If .Cells.Count > 1 Then
BoldChars = CVErr(xlErrRef)
Else
For i = 1 To .Characters.Count
nCount = nCount - .Characters(i, 1).Font.Bold
Next i
BoldChars = nCount
End If
End With
End Function


In article <7C1245CB-6398-415A-AA08-(E-Mail Removed)>,
Duddly Dummy <Duddly (E-Mail Removed)> wrote:

> I need to create 2 cells from one cell based on Bold Type. The Bold type
> characters (name) will be copied into one new cell with the rest of the
> characters (registration number, color(bay/chestnut) and dates) in a 2nd new
> cell. The original cell can contain up to 28 alpha/numeric characters. How
> can I count the number of Bold Type characters in a cell? I will be working
> with several hundred original mixed cells.
>
> EX:NAME ahr#1234567 1989 (with NAME being bold type.)
>
> Thanks in advance for your help!!

 
Reply With Quote
 
=?Utf-8?B?Um9uIENvZGVycmU=?=
Guest
Posts: n/a
 
      8th Apr 2007
Possible alternative?

First....Create this UDF in a general module:

'--------Start_of_Code---------
'PullBold: returns from the 1st bold char in a cell through the last
'contiguous bold char (ignoring subsequent bold chars)

Public Function PullBold(ByRef RefCell As Range) As Variant
Dim strText As String
Dim iRefLen As Integer
Dim iChrCtr As Integer
Dim oChar As Characters
Dim blnHasBold As Boolean

Dim strBullpen
strBullpen = ""

Set RefCell = RefCell.Cells(1.1)

iRefLen = Len(RefCell.Text)
If iRefLen > 0 Then
With RefCell
For iChrCtr = 1 To Len(RefCell.Text)
Set oChar = .Characters(iChrCtr, 1)

If oChar.Font.FontStyle = "Bold" Then
blnHasBold = True
strBullpen = strBullpen & oChar.Text
Else
If blnHasBold = True Then
Exit For
End If
End If
Next iChrCtr
End With 'RefCell
End If
PullBold = strBullpen
End Function
'--------End_of_Code---------

Then....in your workbook
If A1: Lily of the Valley ahr#1234567 1989
(with "Lily of the Valley" being bold type.)

B1: =PullBold(A1)
Returns: Lily of the Valley

C1: =TRIM(SUBSTITUTE(A1,B1,""))
Returns: ahr#1234567 1989

Copy both functions down as far as you need.

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"Duddly Dummy" wrote:

> I need to create 2 cells from one cell based on Bold Type. The Bold type
> characters (name) will be copied into one new cell with the rest of the
> characters (registration number, color(bay/chestnut) and dates) in a 2nd new
> cell. The original cell can contain up to 28 alpha/numeric characters. How
> can I count the number of Bold Type characters in a cell? I will be working
> with several hundred original mixed cells.
>
> EX:NAME ahr#1234567 1989 (with NAME being bold type.)
>
> Thanks in advance for your help!!
>
>

 
Reply With Quote
 
Bernard Liengme
Guest
Posts: n/a
 
      8th Apr 2007
I have never seen the syntax (ByRef rCell As Excel.Range).
Can you please expand on the 'Excel.Range' data type
Thanks
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"JE McGimpsey" <(E-Mail Removed)> wrote in message
news:jemcgimpsey-(E-Mail Removed)...
> ONe wa:
>
> Public Function BoldChars(ByRef rCell As Excel.Range) As Variant
> Dim nCount As Long
> Dim i As Long
> With rCell
> If .Cells.Count > 1 Then
> BoldChars = CVErr(xlErrRef)
> Else
> For i = 1 To .Characters.Count
> nCount = nCount - .Characters(i, 1).Font.Bold
> Next i
> BoldChars = nCount
> End If
> End With
> End Function
>
>
> In article <7C1245CB-6398-415A-AA08-(E-Mail Removed)>,
> Duddly Dummy <Duddly (E-Mail Removed)> wrote:
>
>> I need to create 2 cells from one cell based on Bold Type. The Bold type
>> characters (name) will be copied into one new cell with the rest of the
>> characters (registration number, color(bay/chestnut) and dates) in a 2nd
>> new
>> cell. The original cell can contain up to 28 alpha/numeric characters.
>> How
>> can I count the number of Bold Type characters in a cell? I will be
>> working
>> with several hundred original mixed cells.
>>
>> EX:NAME ahr#1234567 1989 (with NAME being bold type.)
>>
>> Thanks in advance for your help!!



 
Reply With Quote
 
=?Utf-8?B?RHVkZGx5IER1bW15?=
Guest
Posts: n/a
 
      8th Apr 2007
Thanks for responding quickly!! I will try this and let you know.

"Ron Coderre" wrote:

> Possible alternative?
>
> First....Create this UDF in a general module:
>
> '--------Start_of_Code---------
> 'PullBold: returns from the 1st bold char in a cell through the last
> 'contiguous bold char (ignoring subsequent bold chars)
>
> Public Function PullBold(ByRef RefCell As Range) As Variant
> Dim strText As String
> Dim iRefLen As Integer
> Dim iChrCtr As Integer
> Dim oChar As Characters
> Dim blnHasBold As Boolean
>
> Dim strBullpen
> strBullpen = ""
>
> Set RefCell = RefCell.Cells(1.1)
>
> iRefLen = Len(RefCell.Text)
> If iRefLen > 0 Then
> With RefCell
> For iChrCtr = 1 To Len(RefCell.Text)
> Set oChar = .Characters(iChrCtr, 1)
>
> If oChar.Font.FontStyle = "Bold" Then
> blnHasBold = True
> strBullpen = strBullpen & oChar.Text
> Else
> If blnHasBold = True Then
> Exit For
> End If
> End If
> Next iChrCtr
> End With 'RefCell
> End If
> PullBold = strBullpen
> End Function
> '--------End_of_Code---------
>
> Then....in your workbook
> If A1: Lily of the Valley ahr#1234567 1989
> (with "Lily of the Valley" being bold type.)
>
> B1: =PullBold(A1)
> Returns: Lily of the Valley
>
> C1: =TRIM(SUBSTITUTE(A1,B1,""))
> Returns: ahr#1234567 1989
>
> Copy both functions down as far as you need.
>
> Is that something you can work with?
> ***********
> Regards,
> Ron
>
> XL2002, WinXP
>
>
> "Duddly Dummy" wrote:
>
> > I need to create 2 cells from one cell based on Bold Type. The Bold type
> > characters (name) will be copied into one new cell with the rest of the
> > characters (registration number, color(bay/chestnut) and dates) in a 2nd new
> > cell. The original cell can contain up to 28 alpha/numeric characters. How
> > can I count the number of Bold Type characters in a cell? I will be working
> > with several hundred original mixed cells.
> >
> > EX:NAME ahr#1234567 1989 (with NAME being bold type.)
> >
> > Thanks in advance for your help!!
> >
> >

 
Reply With Quote
 
JE McGimpsey
Guest
Posts: n/a
 
      8th Apr 2007
The default object for the Range property is Application, in this case
Excel.

Not usually required, but if one is working with more than one app, it
disambiguates which app's Range is to be used.

Don't remember if all versions of XL automatically use Excel.Range for
the arguments of the event macros they generate, but all versions I've
checked do.

In article <(E-Mail Removed)>,
"Bernard Liengme" <(E-Mail Removed)> wrote:

> I have never seen the syntax (ByRef rCell As Excel.Range).
> Can you please expand on the 'Excel.Range' data type

 
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
Re: How to count the number of letters in a cell? Rick Rothstein \(MVP - VB\) Microsoft Excel Worksheet Functions 5 22nd Aug 2008 09:34 PM
How to count number of Cell have Strike Through Effect & Bold as font style. Akash Maheshwari Microsoft Excel Misc 6 29th Jun 2007 09:39 PM
How to count number of Cell have Strike Through Effect & Bold as font style. Akash Microsoft Excel Programming 10 28th Jun 2007 06:28 AM
Extract bold letters in a cell =?Utf-8?B?aGJhbXNl?= Microsoft Excel Worksheet Functions 1 21st Mar 2006 08:35 AM
RE: Extract bold letters in a cell =?Utf-8?B?U3RlZmk=?= Microsoft Excel Worksheet Functions 0 20th Mar 2006 02:51 PM


Features
 

Advertising
 

Newsgroups
 


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