A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Extract all letters from a cell sentence



 
 
Thread Tools Display Modes
  #1  
Old December 13th, 2007, 10:59 PM posted to microsoft.public.excel.worksheet.functions
michaelxhermes[_2_]
external usenet poster
 
Posts: 1
Default Extract all letters from a cell sentence

Extract all letters from a text word or sentence

I would like to extract all the letters from a sentence which is entered in a
cell. I need each of the letters separately to “encrypt” them, I can then
can concatenate them back to form the encrypted sentence. (for a school
lesson on encryption)

I know I can use MID() function to extract each letter

But for this I need to have the position of the letter I want in the
function =MID(A1,start,1) but start increases by one for each letter, so
I need to hard code the start from 1 to say 50 to extract each letter in
turn

Is there any other way I can do this? So I don’t have to hard code and so I
can have this extract working for any length of initial sentence!

I know I could do this is VB code but was just wondering if anyone knows a
simpler solution using the normal excel functions?

Thanks for your help

Michael

  #2  
Old December 13th, 2007, 11:10 PM posted to microsoft.public.excel.worksheet.functions
Don Guillett
external usenet poster
 
Posts: 6,167
Default Extract all letters from a cell sentence

Not exactly sure what you are doing but this should help
Sub getletterstostring()
mc = Application.Trim(ActiveCell)
For i = 1 To Len(mc)
'If Mid(mc, i, 1) " " Then MsgBox Mid(mc, i, 1)
If Mid(mc, i, 1) " " Then ms = ms & Mid(mc, i, 1)
Next i
MsgBox ms
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"michaelxhermes" u39868@uwe wrote in message news:7ca560cc68cad@uwe...
Extract all letters from a text word or sentence

I would like to extract all the letters from a sentence which is entered
in a
cell. I need each of the letters separately to “encrypt” them, I can then
can concatenate them back to form the encrypted sentence. (for a school
lesson on encryption)

I know I can use MID() function to extract each letter

But for this I need to have the position of the letter I want in the
function =MID(A1,start,1) but start increases by one for each letter,
so
I need to hard code the start from 1 to say 50 to extract each letter in
turn

Is there any other way I can do this? So I don’t have to hard code and so
I
can have this extract working for any length of initial sentence!

I know I could do this is VB code but was just wondering if anyone knows
a
simpler solution using the normal excel functions?

Thanks for your help

Michael


  #3  
Old December 14th, 2007, 12:15 AM posted to microsoft.public.excel.worksheet.functions
Gord Dibben
external usenet poster
 
Posts: 20,252
Default Extract all letters from a cell sentence

This is the sentence of close to 50 chars in A1

=MID($A$1,ROW(),1) entered in B1 and dragged down.

Will return letters and spaces.


Gord Dibben MS Excel MVP


On Thu, 13 Dec 2007 22:59:42 GMT, "michaelxhermes" u39868@uwe wrote:

Extract all letters from a text word or sentence

I would like to extract all the letters from a sentence which is entered in a
cell. I need each of the letters separately to encrypt them, I can then
can concatenate them back to form the encrypted sentence. (for a school
lesson on encryption)

I know I can use MID() function to extract each letter

But for this I need to have the position of the letter I want in the
function =MID(A1,start,1) but start increases by one for each letter, so
I need to hard code the start from 1 to say 50 to extract each letter in
turn

Is there any other way I can do this? So I dont have to hard code and so I
can have this extract working for any length of initial sentence!

I know I could do this is VB code but was just wondering if anyone knows a
simpler solution using the normal excel functions?

Thanks for your help

Michael


  #4  
Old December 14th, 2007, 12:38 PM posted to microsoft.public.excel.worksheet.functions
michaelxhermes via OfficeKB.com
external usenet poster
 
Posts: 5
Default Extract all letters from a cell sentence

Thanks very much Gord and Don

I used the column() function to give me letter postions to extract

But now I have a different problem

I need to join a long list of 1 char cells back to one cell –one word in the
one cell

=CONCATENATE(C40,D40,E40,F40,G40,H40,I40,J40,K40,L 40,M40,N40,O40,P40,Q40)

This will work but is there any other way of doing this so I don’t have to
list all these and more cells?

Thanks

Michael


Gord Dibben wrote:
This is the sentence of close to 50 chars in A1

=MID($A$1,ROW(),1) entered in B1 and dragged down.

Will return letters and spaces.

Gord Dibben MS Excel MVP

Extract all letters from a text word or sentence

[quoted text clipped - 19 lines]

Michael


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200712/1

  #5  
Old December 14th, 2007, 06:21 PM posted to microsoft.public.excel.worksheet.functions
Gord Dibben
external usenet poster
 
Posts: 20,252
Default Extract all letters from a cell sentence

UDF.................

Function ConCatRange(CellBlock As Range) As String
Dim Cell As Range
Dim sbuf As String
For Each Cell In CellBlock
If Len(Cell.text) 0 Then sbuf = sbuf & Cell.text & ""
Next
ConCatRange = Left(sbuf, Len(sbuf) - 1)
End Function

=ConCatRange(C40:Q40)

Macro..........................

Sub ConCat_Cells()
Dim X As Range
Dim y As Range
Dim z As Range
Dim w As String
Dim sbuf As String
On Error GoTo endit
w = InputBox("Enter a De-limiter if Desired")
Set z = Application.InputBox("Select Destination Cell", _
"Destination Cell", , , , , , 8)
Application.SendKeys "+{F8}"
Set X = Application.InputBox("Select Cells, Contiguous or Non-Contiguous", _
"Cells Selection", , , , , , 8)
For Each y In X
If Len(y.text) 0 Then sbuf = sbuf & y.text & w
Next
z = Left(sbuf, Len(sbuf) - Len(w))
Exit Sub
endit:
MsgBox "Nothing Selected. Please try again."
End Sub


Gord

On Fri, 14 Dec 2007 12:38:56 GMT, "michaelxhermes via OfficeKB.com" u39868@uwe
wrote:

Thanks very much Gord and Don

I used the column() function to give me letter postions to extract

But now I have a different problem

I need to join a long list of 1 char cells back to one cell one word in the
one cell

=CONCATENATE(C40,D40,E40,F40,G40,H40,I40,J40,K40, L40,M40,N40,O40,P40,Q40)

This will work but is there any other way of doing this so I dont have to
list all these and more cells?

Thanks

Michael


Gord Dibben wrote:
This is the sentence of close to 50 chars in A1

=MID($A$1,ROW(),1) entered in B1 and dragged down.

Will return letters and spaces.

Gord Dibben MS Excel MVP

Extract all letters from a text word or sentence

[quoted text clipped - 19 lines]

Michael


  #6  
Old December 14th, 2007, 06:59 PM posted to microsoft.public.excel.worksheet.functions
michaelxhermes via OfficeKB.com
external usenet poster
 
Posts: 5
Default Extract all letters from a cell sentence

Thanks Gord for your time and interest!

Much appreciated

I will try you solution now

Regards

Michael
Gord Dibben wrote:
UDF.................

Function ConCatRange(CellBlock As Range) As String
Dim Cell As Range
Dim sbuf As String
For Each Cell In CellBlock
If Len(Cell.text) 0 Then sbuf = sbuf & Cell.text & ""
Next
ConCatRange = Left(sbuf, Len(sbuf) - 1)
End Function

=ConCatRange(C40:Q40)

Macro..........................

Sub ConCat_Cells()
Dim X As Range
Dim y As Range
Dim z As Range
Dim w As String
Dim sbuf As String
On Error GoTo endit
w = InputBox("Enter a De-limiter if Desired")
Set z = Application.InputBox("Select Destination Cell", _
"Destination Cell", , , , , , 8)
Application.SendKeys "+{F8}"
Set X = Application.InputBox("Select Cells, Contiguous or Non-Contiguous", _
"Cells Selection", , , , , , 8)
For Each y In X
If Len(y.text) 0 Then sbuf = sbuf & y.text & w
Next
z = Left(sbuf, Len(sbuf) - Len(w))
Exit Sub
endit:
MsgBox "Nothing Selected. Please try again."
End Sub

Gord

Thanks very much Gord and Don

[quoted text clipped - 27 lines]

Michael


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200712/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:43 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.