PC Review


Reply
Thread Tools Rate Thread

Cut and remove last text

 
 
Jeffery B Paarsa
Guest
Posts: n/a
 
      8th Oct 2009
Hello

The texts are comming in the following format:
5121 W Crystal Ln Santa Ana Ca 927041924
I wrote the following to extract the last piece of text which is Zip code,
Option Explicit

Sub LastWD()
Dim ws As Worksheet
Dim lastrow As Long
Dim i As Long
Dim rng As Range
Set ws = Worksheets("United Care")
lastrow = ws.Cells(Rows.Count, "F").End(xlUp).Row

For i = 1 To lastrow
Set rng = ws.Range("F" & i)
ws.Range("G" & i).Value = Right(rng, Len(rng) - InStrRev(ws.Range("F" &
i).Value, " "))

Next

End Sub

After copying the Zip code into G column I would like to remove the Zip code
and let the text in Column F be "5121 W Crystal Ln Santa Ana Ca"

How can I do that?
--
Jeff B Paarsa
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      8th Oct 2009
Replace the for loop with the below

For i = 1 To lastrow
Set rng = ws.Range("F" & i)
ws.Range("G" & i).Value = Mid(rng, InStrRev(rng.Value, " ") + 1)
ws.Range("I" & i).Value = Left(rng, InStrRev(rng.Value, " ") - 1)
Next

If this post helps click Yes
---------------
Jacob Skaria


"Jeffery B Paarsa" wrote:

> Hello
>
> The texts are comming in the following format:
> 5121 W Crystal Ln Santa Ana Ca 927041924
> I wrote the following to extract the last piece of text which is Zip code,
> Option Explicit
>
> Sub LastWD()
> Dim ws As Worksheet
> Dim lastrow As Long
> Dim i As Long
> Dim rng As Range
> Set ws = Worksheets("United Care")
> lastrow = ws.Cells(Rows.Count, "F").End(xlUp).Row
>
> For i = 1 To lastrow
> Set rng = ws.Range("F" & i)
> ws.Range("G" & i).Value = Right(rng, Len(rng) - InStrRev(ws.Range("F" &
> i).Value, " "))
>
> Next
>
> End Sub
>
> After copying the Zip code into G column I would like to remove the Zip code
> and let the text in Column F be "5121 W Crystal Ln Santa Ana Ca"
>
> How can I do that?
> --
> Jeff B Paarsa

 
Reply With Quote
 
Cut and remove last text
Guest
Posts: n/a
 
      8th Oct 2009
Thanks, but it did not work... This what I changed my code to:
Option Explicit

Sub LastWD()
Dim ws As Worksheet
Dim lastrow As Long
Dim i As Long
Dim rng As Range
Set ws = Worksheets("United Care")
lastrow = ws.Cells(Rows.Count, "F").End(xlUp).Row

For i = 1 To lastrow
Set rng = ws.Range("F" & i)
ws.Range("G" & i).Value = Mid(rng, InStrRev(rng.Value, " ") + 1)
ws.Range("I" & i).Value = Left(rng, InStrRev(rng.Value, " ") - 1)
Next


End Sub

Here is what I got after the code ran:
Column F:
5121 W Crystal Ln Santa Ana Ca 927041924
Column G:
927041924
Column F was supposed to have:
5121 W Crystal Ln Santa Ana Ca after removing the zip code..

Regards,

Jeff Paarsa



"Jacob Skaria" wrote:

> Replace the for loop with the below
>
> For i = 1 To lastrow
> Set rng = ws.Range("F" & i)
> ws.Range("G" & i).Value = Mid(rng, InStrRev(rng.Value, " ") + 1)
> ws.Range("I" & i).Value = Left(rng, InStrRev(rng.Value, " ") - 1)
> Next
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Jeffery B Paarsa" wrote:
>
> > Hello
> >
> > The texts are comming in the following format:
> > 5121 W Crystal Ln Santa Ana Ca 927041924
> > I wrote the following to extract the last piece of text which is Zip code,
> > Option Explicit
> >
> > Sub LastWD()
> > Dim ws As Worksheet
> > Dim lastrow As Long
> > Dim i As Long
> > Dim rng As Range
> > Set ws = Worksheets("United Care")
> > lastrow = ws.Cells(Rows.Count, "F").End(xlUp).Row
> >
> > For i = 1 To lastrow
> > Set rng = ws.Range("F" & i)
> > ws.Range("G" & i).Value = Right(rng, Len(rng) - InStrRev(ws.Range("F" &
> > i).Value, " "))
> >
> > Next
> >
> > End Sub
> >
> > After copying the Zip code into G column I would like to remove the Zip code
> > and let the text in Column F be "5121 W Crystal Ln Santa Ana Ca"
> >
> > How can I do that?
> > --
> > Jeff B Paarsa

 
Reply With Quote
 
Cut and remove last text
Guest
Posts: n/a
 
      8th Oct 2009
Thanks, but it did not work... This what I changed my code to:
Option Explicit

Sub LastWD()
Dim ws As Worksheet
Dim lastrow As Long
Dim i As Long
Dim rng As Range
Set ws = Worksheets("United Care")
lastrow = ws.Cells(Rows.Count, "F").End(xlUp).Row

For i = 1 To lastrow
Set rng = ws.Range("F" & i)
ws.Range("G" & i).Value = Mid(rng, InStrRev(rng.Value, " ") + 1)
ws.Range("I" & i).Value = Left(rng, InStrRev(rng.Value, " ") - 1)
Next


End Sub

Here is what I got after the code ran:
Column F:
5121 W Crystal Ln Santa Ana Ca 927041924
Column G:
927041924
Column F was supposed to have:
5121 W Crystal Ln Santa Ana Ca after removing the zip code..

Regards,

Jeff Paarsa

"Jacob Skaria" wrote:

> Replace the for loop with the below
>
> For i = 1 To lastrow
> Set rng = ws.Range("F" & i)
> ws.Range("G" & i).Value = Mid(rng, InStrRev(rng.Value, " ") + 1)
> ws.Range("I" & i).Value = Left(rng, InStrRev(rng.Value, " ") - 1)
> Next
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Jeffery B Paarsa" wrote:
>
> > Hello
> >
> > The texts are comming in the following format:
> > 5121 W Crystal Ln Santa Ana Ca 927041924
> > I wrote the following to extract the last piece of text which is Zip code,
> > Option Explicit
> >
> > Sub LastWD()
> > Dim ws As Worksheet
> > Dim lastrow As Long
> > Dim i As Long
> > Dim rng As Range
> > Set ws = Worksheets("United Care")
> > lastrow = ws.Cells(Rows.Count, "F").End(xlUp).Row
> >
> > For i = 1 To lastrow
> > Set rng = ws.Range("F" & i)
> > ws.Range("G" & i).Value = Right(rng, Len(rng) - InStrRev(ws.Range("F" &
> > i).Value, " "))
> >
> > Next
> >
> > End Sub
> >
> > After copying the Zip code into G column I would like to remove the Zip code
> > and let the text in Column F be "5121 W Crystal Ln Santa Ana Ca"
> >
> > How can I do that?
> > --
> > Jeff B Paarsa

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      8th Oct 2009
Hi Jeffery

In the earlier post I have referenced to ColI change that to F...as below

For i = 1 To lastrow
Set rng = ws.Range("F" & i)
ws.Range("G" & i).Value = Mid(rng, InStrRev(rng.Value, " ") + 1)
ws.Range("F" & i).Value = Left(rng, InStrRev(rng.Value, " ") - 1)
Next

If this post helps click Yes
---------------
Jacob Skaria


"Cut and remove last text" wrote:

> Thanks, but it did not work... This what I changed my code to:
> Option Explicit
>
> Sub LastWD()
> Dim ws As Worksheet
> Dim lastrow As Long
> Dim i As Long
> Dim rng As Range
> Set ws = Worksheets("United Care")
> lastrow = ws.Cells(Rows.Count, "F").End(xlUp).Row
>
> For i = 1 To lastrow
> Set rng = ws.Range("F" & i)
> ws.Range("G" & i).Value = Mid(rng, InStrRev(rng.Value, " ") + 1)
> ws.Range("I" & i).Value = Left(rng, InStrRev(rng.Value, " ") - 1)
> Next
>
>
> End Sub
>
> Here is what I got after the code ran:
> Column F:
> 5121 W Crystal Ln Santa Ana Ca 927041924
> Column G:
> 927041924
> Column F was supposed to have:
> 5121 W Crystal Ln Santa Ana Ca after removing the zip code..
>
> Regards,
>
> Jeff Paarsa
>
> "Jacob Skaria" wrote:
>
> > Replace the for loop with the below
> >
> > For i = 1 To lastrow
> > Set rng = ws.Range("F" & i)
> > ws.Range("G" & i).Value = Mid(rng, InStrRev(rng.Value, " ") + 1)
> > ws.Range("I" & i).Value = Left(rng, InStrRev(rng.Value, " ") - 1)
> > Next
> >
> > If this post helps click Yes
> > ---------------
> > Jacob Skaria
> >
> >
> > "Jeffery B Paarsa" wrote:
> >
> > > Hello
> > >
> > > The texts are comming in the following format:
> > > 5121 W Crystal Ln Santa Ana Ca 927041924
> > > I wrote the following to extract the last piece of text which is Zip code,
> > > Option Explicit
> > >
> > > Sub LastWD()
> > > Dim ws As Worksheet
> > > Dim lastrow As Long
> > > Dim i As Long
> > > Dim rng As Range
> > > Set ws = Worksheets("United Care")
> > > lastrow = ws.Cells(Rows.Count, "F").End(xlUp).Row
> > >
> > > For i = 1 To lastrow
> > > Set rng = ws.Range("F" & i)
> > > ws.Range("G" & i).Value = Right(rng, Len(rng) - InStrRev(ws.Range("F" &
> > > i).Value, " "))
> > >
> > > Next
> > >
> > > End Sub
> > >
> > > After copying the Zip code into G column I would like to remove the Zip code
> > > and let the text in Column F be "5121 W Crystal Ln Santa Ana Ca"
> > >
> > > How can I do that?
> > > --
> > > Jeff B Paarsa

 
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
How do i remove text effects (blinking text) from my signature? =?Utf-8?B?QnJvYWRjYXN0IE1hcmtldGluZyAmIEVudGVydGFp Microsoft Access Getting Started 1 7th Aug 2006 08:09 PM
Re: want to remove all text characters equal to one character in length from text string CLR Microsoft Excel Worksheet Functions 0 18th Apr 2005 09:56 PM
Re: want to remove all text characters equal to one character in length from text string CLR Microsoft Excel Worksheet Functions 0 18th Apr 2005 12:25 AM
text gone in add/remove programs area. can't highlight text in em =?Utf-8?B?amVycnkgYi4=?= Microsoft Windows 2000 1 21st Oct 2004 01:00 PM
Remove add/remove programs text mur Windows XP General 3 16th Jun 2004 01:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:12 AM.