Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Formula Help - Split capital letters from first part of string

Hello,

I have searched the web but can't seem to find the solution for this
problem. I have a string of data in a column of cells that look like this:

COMPANY NAME Contact Person Address
COMPANY NAME Contact Person Address

I need to pull the company name (which are in all caps) from the first part
of this string for each cell. How do I get Excel to pull the company name
(anywhere from 1 words to 6 or 7 words) and leave the rest?

Thanks in advance for your help!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Formula Help - Split capital letters from first part of string

HI,

Try this. ALT+F11 tp open Vb editor. Right click 'This workbook' and insert
module and paste the code below in.

Call with

=getcaps(a1)

where A1 contains the string. Drag down as required.


Function getcaps(rng As Range) As String
For x = 1 To Len(rng)
If Mid(rng, x, 1) Like "[A-Z]" And _
Not Mid(rng, x + 1, 1) Like "[a-z]" Then
If Mid(rng, x + 1, 1) < " " Then
getcaps = getcaps & Mid(rng, x, 1)
Else
getcaps = getcaps & Mid(rng, x, 1) & " "
End If
End If
Next
End Function
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Beverly-Texas" wrote:

Hello,

I have searched the web but can't seem to find the solution for this
problem. I have a string of data in a column of cells that look like this:

COMPANY NAME Contact Person Address
COMPANY NAME Contact Person Address

I need to pull the company name (which are in all caps) from the first part
of this string for each cell. How do I get Excel to pull the company name
(anywhere from 1 words to 6 or 7 words) and leave the rest?

Thanks in advance for your help!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Formula Help - Split capital letters from first part of string

Beverly,

I should have added that to work the relies on there NOT being any 2 or more
consecutive capital letters after the company name

COMPANY NAME Contact Person Address

In your example above you show Proper case for the address so the UDF will
ignore them
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Mike H" wrote:

HI,

Try this. ALT+F11 tp open Vb editor. Right click 'This workbook' and insert
module and paste the code below in.

Call with

=getcaps(a1)

where A1 contains the string. Drag down as required.


Function getcaps(rng As Range) As String
For x = 1 To Len(rng)
If Mid(rng, x, 1) Like "[A-Z]" And _
Not Mid(rng, x + 1, 1) Like "[a-z]" Then
If Mid(rng, x + 1, 1) < " " Then
getcaps = getcaps & Mid(rng, x, 1)
Else
getcaps = getcaps & Mid(rng, x, 1) & " "
End If
End If
Next
End Function
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Beverly-Texas" wrote:

Hello,

I have searched the web but can't seem to find the solution for this
problem. I have a string of data in a column of cells that look like this:

COMPANY NAME Contact Person Address
COMPANY NAME Contact Person Address

I need to pull the company name (which are in all caps) from the first part
of this string for each cell. How do I get Excel to pull the company name
(anywhere from 1 words to 6 or 7 words) and leave the rest?

Thanks in advance for your help!

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
Extract Capital Letters jnf40 Excel Discussion (Misc queries) 1 April 10th 08 09:14 PM
how to change small letters to capital letters HOW TO CHANGE Excel Discussion (Misc queries) 4 May 30th 07 01:12 AM
how do i turn all letters into capital letters? KeithT Excel Discussion (Misc queries) 3 May 11th 07 02:13 PM
Capital Letters Only Simon Jefford Excel Discussion (Misc queries) 2 February 2nd 06 06:04 PM
Capital Letters Gaute Excel Worksheet Functions 4 March 9th 05 09:55 AM


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