ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Marco - I need to trim/move the text from the beginning of each ce (https://www.excelbanter.com/excel-programming/418099-marco-i-need-trim-move-text-beginning-each-ce.html)

suestew

Marco - I need to trim/move the text from the beginning of each ce
 
I need to cut everything up to and including "v." from each row. The first
row below should read "County of Suffolk, 2007 WL 4565160 (E.D.N.Y. Dec. 21,
2007)"

Toussie v. County of Suffolk, 2007 WL 4565160 (E.D.N.Y. Dec. 21, 2007)
TPS, Inc. v. United States Dept. of Defense, 330 F.3d 1191 (9th Cir. 2003)
Tracy v. Fin. Ins. Mgmt. Corp., 2005 WL 2100261 (S.D. Ind. Aug. 22, 2005)
Trammell v. Anderson Coll., 2006 WL 1997425 (D.S.C. July 17, 2006)

Any help?

Don Guillett

Marco - I need to trim/move the text from the beginning of each ce
 
Sub parsestring1()
On Error Resume Next
For Each c In Range("d3:d7")

x = InStr(c, "v") + 2
c.Offset(, 1) = Right(c, Len(c) - x)
'above for testing if OK delete and uncomment below line
'c.value = Right(c, Len(c) - x)

Next c
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"suestew" wrote in message
...
I need to cut everything up to and including "v." from each row. The first
row below should read "County of Suffolk, 2007 WL 4565160 (E.D.N.Y. Dec.
21,
2007)"

Toussie v. County of Suffolk, 2007 WL 4565160 (E.D.N.Y. Dec. 21, 2007)
TPS, Inc. v. United States Dept. of Defense, 330 F.3d 1191 (9th Cir. 2003)
Tracy v. Fin. Ins. Mgmt. Corp., 2005 WL 2100261 (S.D. Ind. Aug. 22, 2005)
Trammell v. Anderson Coll., 2006 WL 1997425 (D.S.C. July 17, 2006)

Any help?



JLGWhiz

Marco - I need to trim/move the text from the beginning of each ce
 
You didn't say which column the data is in. This macro assumes it is in
column A.
You can modify accordingly.

Sub getCase()
Dim x As Long, s As Long, c As Range
For Each c In Range("A" & Cells(Rows.Count, 1).End(xlUp).Row)
If InStr(c.Value, "v") 0 Then
x = InStr(Range("A2"), "v") + 2
s = Right(Range("A2"), Len(Range("A2").Value) - x)
MsgBox s 'For test only, substitute cells posting code
End If
Next
End Sub






"suestew" wrote:

I need to cut everything up to and including "v." from each row. The first
row below should read "County of Suffolk, 2007 WL 4565160 (E.D.N.Y. Dec. 21,
2007)"

Toussie v. County of Suffolk, 2007 WL 4565160 (E.D.N.Y. Dec. 21, 2007)
TPS, Inc. v. United States Dept. of Defense, 330 F.3d 1191 (9th Cir. 2003)
Tracy v. Fin. Ins. Mgmt. Corp., 2005 WL 2100261 (S.D. Ind. Aug. 22, 2005)
Trammell v. Anderson Coll., 2006 WL 1997425 (D.S.C. July 17, 2006)

Any help?


JLGWhiz

Marco - I need to trim/move the text from the beginning of eac
 
Just realized I left test syntax in the code.
This will work better.

Sub getCase()
For Each c In Range("A" & Cells(Rows.Count, 1).End(xlUp).Row)
If InStr(c.Value, "v") 0 Then
x = InStr(c.Value, "v") + 2
s = Right(c.Value, Len(Range("A2").Value) - x)
MsgBox s
End If
Next
End Sub

If any of the lines do not have a space after v. then it will clip the first
letter of the next word off. Be sure to edit for that.

"JLGWhiz" wrote:

You didn't say which column the data is in. This macro assumes it is in
column A.
You can modify accordingly.

Sub getCase()
Dim x As Long, s As Long, c As Range
For Each c In Range("A" & Cells(Rows.Count, 1).End(xlUp).Row)
If InStr(c.Value, "v") 0 Then
x = InStr(Range("A2"), "v") + 2
s = Right(Range("A2"), Len(Range("A2").Value) - x)
MsgBox s 'For test only, substitute cells posting code
End If
Next
End Sub






"suestew" wrote:

I need to cut everything up to and including "v." from each row. The first
row below should read "County of Suffolk, 2007 WL 4565160 (E.D.N.Y. Dec. 21,
2007)"

Toussie v. County of Suffolk, 2007 WL 4565160 (E.D.N.Y. Dec. 21, 2007)
TPS, Inc. v. United States Dept. of Defense, 330 F.3d 1191 (9th Cir. 2003)
Tracy v. Fin. Ins. Mgmt. Corp., 2005 WL 2100261 (S.D. Ind. Aug. 22, 2005)
Trammell v. Anderson Coll., 2006 WL 1997425 (D.S.C. July 17, 2006)

Any help?


Ron Rosenfeld

Marco - I need to trim/move the text from the beginning of each ce
 
On Sun, 5 Oct 2008 13:05:14 -0500, "Don Guillett"
wrote:

Sub parsestring1()
On Error Resume Next
For Each c In Range("d3:d7")

x = InStr(c, "v") + 2
c.Offset(, 1) = Right(c, Len(c) - x)
'above for testing if OK delete and uncomment below line
'c.value = Right(c, Len(c) - x)

Next c
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software


This doesn't work if there is a "v" in the first name. e.g:

Travelers Ins v. Valerie Cohn, 2006 WL 1997425 (D.S.C. July 17, 2006)

--ron

Ron Rosenfeld

Marco - I need to trim/move the text from the beginning of each ce
 
On Sun, 5 Oct 2008 09:36:00 -0700, suestew
wrote:

I need to cut everything up to and including "v." from each row. The first
row below should read "County of Suffolk, 2007 WL 4565160 (E.D.N.Y. Dec. 21,
2007)"

Toussie v. County of Suffolk, 2007 WL 4565160 (E.D.N.Y. Dec. 21, 2007)
TPS, Inc. v. United States Dept. of Defense, 330 F.3d 1191 (9th Cir. 2003)
Tracy v. Fin. Ins. Mgmt. Corp., 2005 WL 2100261 (S.D. Ind. Aug. 22, 2005)
Trammell v. Anderson Coll., 2006 WL 1997425 (D.S.C. July 17, 2006)

Any help?


The macro below will place everything after the "v. " in the cell to the right
of "Selection".

============================================
Sub Defendant()
Dim c As Range
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "^.*\bv\.\s+"

For Each c In Selection
If re.test(c.Value) = False Then
c.Offset(0, 1) = "no ""v. "" in string"
Else
c.Offset(0, 1).Value = re.Replace(c.Value, "")
End If
Next c
End Sub
================================================
--ron

Don Guillett

Marco - I need to trim/move the text from the beginning of each ce
 
Good catch. But it does if you just add a dot after the v
v.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Ron Rosenfeld" wrote in message
...
On Sun, 5 Oct 2008 13:05:14 -0500, "Don Guillett"

wrote:

Sub parsestring1()
On Error Resume Next
For Each c In Range("d3:d7")

x = InStr(c, "v") + 2
c.Offset(, 1) = Right(c, Len(c) - x)
'above for testing if OK delete and uncomment below line
'c.value = Right(c, Len(c) - x)

Next c
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software


This doesn't work if there is a "v" in the first name. e.g:

Travelers Ins v. Valerie Cohn, 2006 WL 1997425 (D.S.C. July 17, 2006)

--ron



Ron Rosenfeld

Marco - I need to trim/move the text from the beginning of each ce
 
On Sun, 5 Oct 2008 15:44:06 -0500, "Don Guillett"
wrote:

Good catch. But it does if you just add a dot after the v
v.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software


Of course <sound of hand slapping side of head.

I didn't look at the code closely, just the results.

It might be more robust, though, if you looked for
<spacev.<space

Probably should be case sensitive also to avoid splitting on a name that
includes a V. (V.S. INT'L is a company name).
--ron

suestew

Marco - I need to trim/move the text from the beginning of eac
 
I'm working in a Mac. None of the macros are working. ??? Or maybe I not
doing something correctly on my end. I'll go try these on a PC but should
there be a problem?

"Ron Rosenfeld" wrote:

On Sun, 5 Oct 2008 09:36:00 -0700, suestew
wrote:

I need to cut everything up to and including "v." from each row. The first
row below should read "County of Suffolk, 2007 WL 4565160 (E.D.N.Y. Dec. 21,
2007)"

Toussie v. County of Suffolk, 2007 WL 4565160 (E.D.N.Y. Dec. 21, 2007)
TPS, Inc. v. United States Dept. of Defense, 330 F.3d 1191 (9th Cir. 2003)
Tracy v. Fin. Ins. Mgmt. Corp., 2005 WL 2100261 (S.D. Ind. Aug. 22, 2005)
Trammell v. Anderson Coll., 2006 WL 1997425 (D.S.C. July 17, 2006)

Any help?


The macro below will place everything after the "v. " in the cell to the right
of "Selection".

============================================
Sub Defendant()
Dim c As Range
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "^.*\bv\.\s+"

For Each c In Selection
If re.test(c.Value) = False Then
c.Offset(0, 1) = "no ""v. "" in string"
Else
c.Offset(0, 1).Value = re.Replace(c.Value, "")
End If
Next c
End Sub
================================================
--ron


Oorang[_3_]

Marco - I need to trim/move the text from the beginning of eac
 

Well that was a little confusing, but I think this might do what you
want.

Code:
--------------------
Sub getCase()
Dim c As Excel.Range
Dim x As Long
Dim s() As String
For Each c In Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row)
s = Split(c.Value, " v. ")
c.Value = s(0)
c.Offset(0, 1).Value = s(1)
Next
End Sub
--------------------


--
Oorang
------------------------------------------------------------------------
Oorang's Profile: http://www.thecodecage.com/forumz/member.php?userid=129
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=88



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com