Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Macro to grab "inbetween words" from a text

Group members and MVP's,

I have a text in range("A1"). Let us assume that the text is C:
\012245\Aeroplane\

I would like to have a macro that grabs the word "plane" from the text
C:\012245\Aeroplane\

Recording a macro doesnt seem to help in this case.

Thanks!
-T

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Macro to grab "inbetween words" from a text

Need more info in order to really help. What is the criteria for the
grabbed text? If all you want is "plane" out of that file you listed,
you could use the Mid function.
These examples assume that the text is in A12.
=MID(A12,15,5)
Or
=RIGHT(SUBSTITUTE(A12,"\",""),5)

Thulasiram wrote:
Group members and MVP's,

I have a text in range("A1"). Let us assume that the text is C:
\012245\Aeroplane\

I would like to have a macro that grabs the word "plane" from the text
C:\012245\Aeroplane\

Recording a macro doesnt seem to help in this case.

Thanks!
-T


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Macro to grab "inbetween words" from a text

On Sep 5, 9:12 am, JW wrote:
Need more info in order to really help. What is the criteria for the
grabbed text? If all you want is "plane" out of that file you listed,
you could use the Mid function.
These examples assume that the text is in A12.
=MID(A12,15,5)
Or
=RIGHT(SUBSTITUTE(A12,"\",""),5)

Thulasiram wrote:
Group members and MVP's,


I have a text in range("A1"). Let us assume that the text is C:
\012245\Aeroplane\


I would like to have a macro that grabs the word "plane" from the text
C:\012245\Aeroplane\


Recording a macro doesnt seem to help in this case.


Thanks!
-T


Thanks! This what I want.. To actaully suit it should have been
=MID(A1,15,5).

Can you give me the VBA code for this. Suppose if I click a command
button, I want this to happen.

sub grab()
...
...
....
end sub

and then

Private Sub CommandButton1_Click()
call grab
End Sub

Thanks!
-T

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Macro to grab "inbetween words" from a text

On Sep 5, 9:12 am, JW wrote:
Need more info in order to really help. What is the criteria for the
grabbed text? If all you want is "plane" out of that file you listed,
you could use the Mid function.
These examples assume that the text is in A12.
=MID(A12,15,5)
Or
=RIGHT(SUBSTITUTE(A12,"\",""),5)

Thulasiram wrote:
Group members and MVP's,


I have a text in range("A1"). Let us assume that the text is C:
\012245\Aeroplane\


I would like to have a macro that grabs the word "plane" from the text
C:\012245\Aeroplane\


Recording a macro doesnt seem to help in this case.


Thanks!
-T


Hi Jeff,

The code you have given counts 15 characters from "left to right" and
then takes 5 characters (plane). How to tweak the code if I have to
make it from "right to left" and take the same 5 characters (plane)?
Please help.. Thanks!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Macro to grab "inbetween words" from a text

That would require some type of criteria as to where to begin the grab
and many characters to include in the grab.

Thulasiram wrote:
On Sep 5, 9:12 am, JW wrote:
Need more info in order to really help. What is the criteria for the
grabbed text? If all you want is "plane" out of that file you listed,
you could use the Mid function.
These examples assume that the text is in A12.
=MID(A12,15,5)
Or
=RIGHT(SUBSTITUTE(A12,"\",""),5)

Thulasiram wrote:
Group members and MVP's,


I have a text in range("A1"). Let us assume that the text is C:
\012245\Aeroplane\


I would like to have a macro that grabs the word "plane" from the text
C:\012245\Aeroplane\


Recording a macro doesnt seem to help in this case.


Thanks!
-T


Hi Jeff,

The code you have given counts 15 characters from "left to right" and
then takes 5 characters (plane). How to tweak the code if I have to
make it from "right to left" and take the same 5 characters (plane)?
Please help.. Thanks!




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Macro to grab "inbetween words" from a text

This will place "plane" in B1 if the string you used in your example
is in A1. This is a very harsh way of doing this as the ranges are
hard coded, but that's about all I can do based on the info you have
provided.
Sub grab()
Range("B1").Value = Mid(Range("A1").Value, 15, 5)
End Sub
Thulasiram wrote:
On Sep 5, 9:12 am, JW wrote:
Need more info in order to really help. What is the criteria for the
grabbed text? If all you want is "plane" out of that file you listed,
you could use the Mid function.
These examples assume that the text is in A12.
=MID(A12,15,5)
Or
=RIGHT(SUBSTITUTE(A12,"\",""),5)

Thulasiram wrote:
Group members and MVP's,


I have a text in range("A1"). Let us assume that the text is C:
\012245\Aeroplane\


I would like to have a macro that grabs the word "plane" from the text
C:\012245\Aeroplane\


Recording a macro doesnt seem to help in this case.


Thanks!
-T


Thanks! This what I want.. To actaully suit it should have been
=MID(A1,15,5).

Can you give me the VBA code for this. Suppose if I click a command
button, I want this to happen.

sub grab()
..
..
...
end sub

and then

Private Sub CommandButton1_Click()
call grab
End Sub

Thanks!
-T


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Macro to grab "inbetween words" from a text

Thanks Jeff. It works. As I asked to you my previous post, the code
you have given counts 15 characters from "left to right" and then
takes 5 characters (plane). How to tweak the code if I have to make it
from "right to left" and take the same 5 characters (plane)?

So, the criteria would be grabbing 5 characters (second to sixth
characters) in the right to left fashion. If the word is Aeroplane\
then the result would be plane. If the word is Elephant, then the
result would be ephan.

-Thulasiram

On Sep 5, 11:56 am, JW wrote:
This will place "plane" in B1 if the string you used in your example
is in A1. This is a very harsh way of doing this as the ranges are
hard coded, but that's about all I can do based on the info you have
provided.
Sub grab()
Range("B1").Value = Mid(Range("A1").Value, 15, 5)
End Sub

Thulasiram wrote:
On Sep 5, 9:12 am, JW wrote:
Need more info in order to really help. What is the criteria for the
grabbed text? If all you want is "plane" out of that file you listed,
you could use the Mid function.
These examples assume that the text is in A12.
=MID(A12,15,5)
Or
=RIGHT(SUBSTITUTE(A12,"\",""),5)


Thulasiram wrote:
Group members and MVP's,


I have a text in range("A1"). Let us assume that the text is C:
\012245\Aeroplane\


I would like to have a macro that grabs the word "plane" from the text
C:\012245\Aeroplane\


Recording a macro doesnt seem to help in this case.


Thanks!
-T


Thanks! This what I want.. To actaully suit it should have been
=MID(A1,15,5).


Can you give me the VBA code for this. Suppose if I click a command
button, I want this to happen.


sub grab()
..
..
...
end sub


and then


Private Sub CommandButton1_Click()
call grab
End Sub


Thanks!
-T



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Macro to grab "inbetween words" from a text

The below formula and/or sub will do what you want. But what to do if
the value in A1 is less than 5 characters in length?
=MID(A1,LEN(A1)-5,5)
Sub grab()
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value)
- 5, 5)
End Sub

Thulasiram wrote:
Thanks Jeff. It works. As I asked to you my previous post, the code
you have given counts 15 characters from "left to right" and then
takes 5 characters (plane). How to tweak the code if I have to make it
from "right to left" and take the same 5 characters (plane)?

So, the criteria would be grabbing 5 characters (second to sixth
characters) in the right to left fashion. If the word is Aeroplane\
then the result would be plane. If the word is Elephant, then the
result would be ephan.

-Thulasiram

On Sep 5, 11:56 am, JW wrote:
This will place "plane" in B1 if the string you used in your example
is in A1. This is a very harsh way of doing this as the ranges are
hard coded, but that's about all I can do based on the info you have
provided.
Sub grab()
Range("B1").Value = Mid(Range("A1").Value, 15, 5)
End Sub

Thulasiram wrote:
On Sep 5, 9:12 am, JW wrote:
Need more info in order to really help. What is the criteria for the
grabbed text? If all you want is "plane" out of that file you listed,
you could use the Mid function.
These examples assume that the text is in A12.
=MID(A12,15,5)
Or
=RIGHT(SUBSTITUTE(A12,"\",""),5)


Thulasiram wrote:
Group members and MVP's,


I have a text in range("A1"). Let us assume that the text is C:
\012245\Aeroplane\


I would like to have a macro that grabs the word "plane" from the text
C:\012245\Aeroplane\


Recording a macro doesnt seem to help in this case.


Thanks!
-T


Thanks! This what I want.. To actaully suit it should have been
=MID(A1,15,5).


Can you give me the VBA code for this. Suppose if I click a command
button, I want this to happen.


sub grab()
..
..
...
end sub


and then


Private Sub CommandButton1_Click()
call grab
End Sub


Thanks!
-T


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Macro to grab "inbetween words" from a text

Jeff,
The code works is super cool!

I now have something like this to answer your question:

If Len(Range("A1").Value) < 5 Then
MsgBox "Not possible"
Else
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 5,
5)
End If

and the other possibility can be

If Len(Range("A1").Value) = 5 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 4,
4)
ElseIf Len(Range("A1").Value) = 4 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 3,
3)
ElseIf Len(Range("A1").Value) = 3 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 2,
2)
ElseIf Len(Range("A1").Value) = 2 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 1,
1)
ElseIf Len(Range("A1").Value) 5 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 5,
5)
ElseIf Len(Range("A1").Value) < 2 Then
MsgBox "Not possible"
End If

Do you know an easier way to do this?

Thanks,
Thulasiram

On Sep 6, 6:08 am, JW wrote:
The below formula and/or sub will do what you want. But what to do if
the value in A1 is less than 5 characters in length?
=MID(A1,LEN(A1)-5,5)
Sub grab()
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value)
- 5, 5)
End Sub

Thulasiramwrote:
Thanks Jeff. It works. As I asked to you my previous post, the code
you have given counts 15 characters from "left to right" and then
takes 5 characters (plane). How to tweak the code if I have to make it
from "right to left" and take the same 5 characters (plane)?


So, the criteria would be grabbing 5 characters (second to sixth
characters) in the right to left fashion. If the word is Aeroplane\
then the result would be plane. If the word is Elephant, then the
result would be ephan.


-Thulasiram


On Sep 5, 11:56 am, JW wrote:
This will place "plane" in B1 if the string you used in your example
is in A1. This is a very harsh way of doing this as the ranges are
hard coded, but that's about all I can do based on the info you have
provided.
Sub grab()
Range("B1").Value = Mid(Range("A1").Value, 15, 5)
End Sub


Thulasiramwrote:
On Sep 5, 9:12 am, JW wrote:
Need more info in order to really help. What is the criteria for the
grabbed text? If all you want is "plane" out of that file you listed,
you could use the Mid function.
These examples assume that the text is in A12.
=MID(A12,15,5)
Or
=RIGHT(SUBSTITUTE(A12,"\",""),5)


Thulasiramwrote:
Group members and MVP's,


I have a text in range("A1"). Let us assume that the text is C:
\012245\Aeroplane\


I would like to have a macro that grabs the word "plane" from the text
C:\012245\Aeroplane\


Recording a macro doesnt seem to help in this case.


Thanks!
-T


Thanks! This what I want.. To actaully suit it should have been
=MID(A1,15,5).


Can you give me the VBA code for this. Suppose if I click a command
button, I want this to happen.


sub grab()
..
..
...
end sub


and then


Private Sub CommandButton1_Click()
call grab
End Sub


Thanks!
-T



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Macro to grab "inbetween words" from a text

Give this a shot.
Dim l As Integer
lgth = Len(Range("A1").Value)
If lgth 5 Then
Range("B1").Value = Mid(Range("A1").Value, lgth - 5, 5)
ElseIf lgth < 2 Then
MsgBox "Not possible"
Else
Range("B1").Value = Mid(Range("A1").Value, lgth - (lgth - 1),
lgth - 1)
End If
Thulasiram wrote:
Jeff,
The code works is super cool!

I now have something like this to answer your question:

If Len(Range("A1").Value) < 5 Then
MsgBox "Not possible"
Else
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 5,
5)
End If

and the other possibility can be

If Len(Range("A1").Value) = 5 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 4,
4)
ElseIf Len(Range("A1").Value) = 4 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 3,
3)
ElseIf Len(Range("A1").Value) = 3 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 2,
2)
ElseIf Len(Range("A1").Value) = 2 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 1,
1)
ElseIf Len(Range("A1").Value) 5 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 5,
5)
ElseIf Len(Range("A1").Value) < 2 Then
MsgBox "Not possible"
End If

Do you know an easier way to do this?

Thanks,
Thulasiram

On Sep 6, 6:08 am, JW wrote:
The below formula and/or sub will do what you want. But what to do if
the value in A1 is less than 5 characters in length?
=MID(A1,LEN(A1)-5,5)
Sub grab()
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value)
- 5, 5)
End Sub

Thulasiramwrote:
Thanks Jeff. It works. As I asked to you my previous post, the code
you have given counts 15 characters from "left to right" and then
takes 5 characters (plane). How to tweak the code if I have to make it
from "right to left" and take the same 5 characters (plane)?


So, the criteria would be grabbing 5 characters (second to sixth
characters) in the right to left fashion. If the word is Aeroplane\
then the result would be plane. If the word is Elephant, then the
result would be ephan.


-Thulasiram


On Sep 5, 11:56 am, JW wrote:
This will place "plane" in B1 if the string you used in your example
is in A1. This is a very harsh way of doing this as the ranges are
hard coded, but that's about all I can do based on the info you have
provided.
Sub grab()
Range("B1").Value = Mid(Range("A1").Value, 15, 5)
End Sub


Thulasiramwrote:
On Sep 5, 9:12 am, JW wrote:
Need more info in order to really help. What is the criteria for the
grabbed text? If all you want is "plane" out of that file you listed,
you could use the Mid function.
These examples assume that the text is in A12.
=MID(A12,15,5)
Or
=RIGHT(SUBSTITUTE(A12,"\",""),5)


Thulasiramwrote:
Group members and MVP's,


I have a text in range("A1"). Let us assume that the text is C:
\012245\Aeroplane\


I would like to have a macro that grabs the word "plane" from the text
C:\012245\Aeroplane\


Recording a macro doesnt seem to help in this case.


Thanks!
-T


Thanks! This what I want.. To actaully suit it should have been
=MID(A1,15,5).


Can you give me the VBA code for this. Suppose if I click a command
button, I want this to happen.


sub grab()
..
..
...
end sub


and then


Private Sub CommandButton1_Click()
call grab
End Sub


Thanks!
-T




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Macro to grab "inbetween words" from a text

Works great!

On Sep 6, 9:37 am, JW wrote:
Give this a shot.
Dim l As Integer
lgth = Len(Range("A1").Value)
If lgth 5 Then
Range("B1").Value = Mid(Range("A1").Value, lgth - 5, 5)
ElseIf lgth < 2 Then
MsgBox "Not possible"
Else
Range("B1").Value = Mid(Range("A1").Value, lgth - (lgth - 1),
lgth - 1)
End If

Thulasiramwrote:
Jeff,
The code works is super cool!


I now have something like this to answer your question:


If Len(Range("A1").Value) < 5 Then
MsgBox "Not possible"
Else
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 5,
5)
End If


and the other possibility can be


If Len(Range("A1").Value) = 5 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 4,
4)
ElseIf Len(Range("A1").Value) = 4 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 3,
3)
ElseIf Len(Range("A1").Value) = 3 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 2,
2)
ElseIf Len(Range("A1").Value) = 2 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 1,
1)
ElseIf Len(Range("A1").Value) 5 Then
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value) - 5,
5)
ElseIf Len(Range("A1").Value) < 2 Then
MsgBox "Not possible"
End If


Do you know an easier way to do this?


Thanks,
Thulasiram


On Sep 6, 6:08 am, JW wrote:
The below formula and/or sub will do what you want. But what to do if
the value in A1 is less than 5 characters in length?
=MID(A1,LEN(A1)-5,5)
Sub grab()
Range("B1").Value = Mid(Range("A1").Value, Len(Range("A1").Value)
- 5, 5)
End Sub


Thulasiramwrote:
Thanks Jeff. It works. As I asked to you my previous post, the code
you have given counts 15 characters from "left to right" and then
takes 5 characters (plane). How to tweak the code if I have to make it
from "right to left" and take the same 5 characters (plane)?


So, the criteria would be grabbing 5 characters (second to sixth
characters) in the right to left fashion. If the word is Aeroplane\
then the result would be plane. If the word is Elephant, then the
result would be ephan.


-Thulasiram


On Sep 5, 11:56 am, JW wrote:
This will place "plane" in B1 if the string you used in your example
is in A1. This is a very harsh way of doing this as the ranges are
hard coded, but that's about all I can do based on the info you have
provided.
Sub grab()
Range("B1").Value = Mid(Range("A1").Value, 15, 5)
End Sub


Thulasiramwrote:
On Sep 5, 9:12 am, JW wrote:
Need more info in order to really help. What is the criteria for the
grabbed text? If all you want is "plane" out of that file you listed,
you could use the Mid function.
These examples assume that the text is in A12.
=MID(A12,15,5)
Or
=RIGHT(SUBSTITUTE(A12,"\",""),5)


Thulasiramwrote:
Group members and MVP's,


I have a text in range("A1"). Let us assume that the text is C:
\012245\Aeroplane\


I would like to have a macro that grabs the word "plane" from the text
C:\012245\Aeroplane\


Recording a macro doesnt seem to help in this case.


Thanks!
-T


Thanks! This what I want.. To actaully suit it should have been
=MID(A1,15,5).


Can you give me the VBA code for this. Suppose if I click a command
button, I want this to happen.


sub grab()
..
..
...
end sub


and then


Private Sub CommandButton1_Click()
call grab
End Sub


Thanks!
-T



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
How can I alphabetize data excluding words like "a" and "the"? Faith Excel Discussion (Misc queries) 6 November 11th 09 05:50 PM
Would I use "Lookup" to pick names for a Christmas grab bag Doebaby Excel Worksheet Functions 13 November 7th 07 11:20 PM
VLOOKUP won't generate correct response for "inbetween" values NavyPianoMan Excel Discussion (Misc queries) 9 August 28th 07 02:28 PM
certain words "CONTAINS" in an free text cell........... Beverly C Excel Discussion (Misc queries) 2 February 6th 07 02:51 PM
Sending macro based e-mail with built-in "Heading" and "Text" Prabha Excel Programming 3 January 17th 05 02:11 PM


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