Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Edye
 
Posts: n/a
Default Need Macro for List of Book Titles

Excel 2003
I have a list of books. About 700 contain a "The" at the beginning. I need
to add ", The" (without quotes) to the end of each one of those book titles
and remove the "The" at the beginning of the title. I recorded a Macro for
it, but each time I use the Macro, it replaces the other cells with the title
of the one which I recorded. Thanks!
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default


Sub BookTitles()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If LCase(Left(Cells(i, "A").Value, 4)) = "the " Then
Cells(i, "A").Value = Right(Cells(i, "A").Value, Len( _
Cells(i, "A").Value) - 4) & ", The"
End If
Next i

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Edye" wrote in message
...
Excel 2003
I have a list of books. About 700 contain a "The" at the beginning. I

need
to add ", The" (without quotes) to the end of each one of those book

titles
and remove the "The" at the beginning of the title. I recorded a Macro

for
it, but each time I use the Macro, it replaces the other cells with the

title
of the one which I recorded. Thanks!



  #3   Report Post  
Edye
 
Posts: n/a
Default

Worked perfectly. THANK YOU for saving me days of work!!!

"Bob Phillips" wrote:


Sub BookTitles()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If LCase(Left(Cells(i, "A").Value, 4)) = "the " Then
Cells(i, "A").Value = Right(Cells(i, "A").Value, Len( _
Cells(i, "A").Value) - 4) & ", The"
End If
Next i

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Edye" wrote in message
...
Excel 2003
I have a list of books. About 700 contain a "The" at the beginning. I

need
to add ", The" (without quotes) to the end of each one of those book

titles
and remove the "The" at the beginning of the title. I recorded a Macro

for
it, but each time I use the Macro, it replaces the other cells with the

title
of the one which I recorded. Thanks!




  #4   Report Post  
Edye
 
Posts: n/a
Default

One more little thing I noticed. There's a space b/w the end of the title
and the ", The". How do I edit the macro to remove that space?

"Bob Phillips" wrote:


Sub BookTitles()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If LCase(Left(Cells(i, "A").Value, 4)) = "the " Then
Cells(i, "A").Value = Right(Cells(i, "A").Value, Len( _
Cells(i, "A").Value) - 4) & ", The"
End If
Next i

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Edye" wrote in message
...
Excel 2003
I have a list of books. About 700 contain a "The" at the beginning. I

need
to add ", The" (without quotes) to the end of each one of those book

titles
and remove the "The" at the beginning of the title. I recorded a Macro

for
it, but each time I use the Macro, it replaces the other cells with the

title
of the one which I recorded. Thanks!




  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default

Sub BookTitles()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If LCase(Left(Cells(i, "A").Value, 4)) = "the " Then
Cells(i, "A").Value = Right(Trim(Cells(i, "A").Value), _
Len(Cells(i, "A").Value) - 4) & ",
The"
End If
Next i

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Edye" wrote in message
...
One more little thing I noticed. There's a space b/w the end of the title
and the ", The". How do I edit the macro to remove that space?

"Bob Phillips" wrote:


Sub BookTitles()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If LCase(Left(Cells(i, "A").Value, 4)) = "the " Then
Cells(i, "A").Value = Right(Cells(i, "A").Value, Len( _
Cells(i, "A").Value) - 4) & ",

The"
End If
Next i

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Edye" wrote in message
...
Excel 2003
I have a list of books. About 700 contain a "The" at the beginning.

I
need
to add ", The" (without quotes) to the end of each one of those book

titles
and remove the "The" at the beginning of the title. I recorded a

Macro
for
it, but each time I use the Macro, it replaces the other cells with

the
title
of the one which I recorded. Thanks!








  #6   Report Post  
Edye
 
Posts: n/a
Default

I get Comple Error: Sub or Function not defined. It highlights the last
"the" (w/o quotes).

"Bob Phillips" wrote:

Sub BookTitles()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If LCase(Left(Cells(i, "A").Value, 4)) = "the " Then
Cells(i, "A").Value = Right(Trim(Cells(i, "A").Value), _
Len(Cells(i, "A").Value) - 4) & ",
The"
End If
Next i

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Edye" wrote in message
...
One more little thing I noticed. There's a space b/w the end of the title
and the ", The". How do I edit the macro to remove that space?

"Bob Phillips" wrote:


Sub BookTitles()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If LCase(Left(Cells(i, "A").Value, 4)) = "the " Then
Cells(i, "A").Value = Right(Cells(i, "A").Value, Len( _
Cells(i, "A").Value) - 4) & ",

The"
End If
Next i

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Edye" wrote in message
...
Excel 2003
I have a list of books. About 700 contain a "The" at the beginning.

I
need
to add ", The" (without quotes) to the end of each one of those book
titles
and remove the "The" at the beginning of the title. I recorded a

Macro
for
it, but each time I use the Macro, it replaces the other cells with

the
title
of the one which I recorded. Thanks!






  #7   Report Post  
Bob Phillips
 
Posts: n/a
Default

Wrap-around Edye. Try this

Sub BookTitles()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If LCase(Left(Cells(i, "A").Value, 4)) = "the " Then
Cells(i, "A").Value = Right(Trim(Cells(i, "A").Value), _
Len(Cells(i, "A").Value) - 4) & ", The"
End If
Next i

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Edye" wrote in message
...
I get Comple Error: Sub or Function not defined. It highlights the last
"the" (w/o quotes).

"Bob Phillips" wrote:

Sub BookTitles()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If LCase(Left(Cells(i, "A").Value, 4)) = "the " Then
Cells(i, "A").Value = Right(Trim(Cells(i, "A").Value), _
Len(Cells(i, "A").Value) - 4) &

",
The"
End If
Next i

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Edye" wrote in message
...
One more little thing I noticed. There's a space b/w the end of the

title
and the ", The". How do I edit the macro to remove that space?

"Bob Phillips" wrote:


Sub BookTitles()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If LCase(Left(Cells(i, "A").Value, 4)) = "the " Then
Cells(i, "A").Value = Right(Cells(i, "A").Value, Len( _
Cells(i, "A").Value) - 4) &

",
The"
End If
Next i

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Edye" wrote in message
...
Excel 2003
I have a list of books. About 700 contain a "The" at the

beginning.
I
need
to add ", The" (without quotes) to the end of each one of those

book
titles
and remove the "The" at the beginning of the title. I recorded a

Macro
for
it, but each time I use the Macro, it replaces the other cells

with
the
title
of the one which I recorded. Thanks!








  #8   Report Post  
David Billigmeier
 
Posts: n/a
Default

You don't need vba, assuming all of the book title formats are the same, i.e.
"The " is the first 4 characters of the title (including the space) you can
use the following formula and just copy down to the end of your list:

=IF(LEFT(A1,4)="the ",CONCATENATE(RIGHT(A1,LEN(A1)-4),", The"),A1)

--
David Billigmeier


"Edye" wrote:

Excel 2003
I have a list of books. About 700 contain a "The" at the beginning. I need
to add ", The" (without quotes) to the end of each one of those book titles
and remove the "The" at the beginning of the title. I recorded a Macro for
it, but each time I use the Macro, it replaces the other cells with the title
of the one which I recorded. Thanks!

  #9   Report Post  
Brian Synowiec
 
Posts: n/a
Default

How about this:
Assuming your book names start in A1, and the titles are less than 100
charecters (increase the 100 in the formula if they are longer);put this in
B1 and copy down:

=MID(A1,4,100)&", The"

Brian


"Edye" wrote:

Excel 2003
I have a list of books. About 700 contain a "The" at the beginning. I need
to add ", The" (without quotes) to the end of each one of those book titles
and remove the "The" at the beginning of the title. I recorded a Macro for
it, but each time I use the Macro, it replaces the other cells with the title
of the one which I recorded. Thanks!

  #10   Report Post  
David Billigmeier
 
Posts: n/a
Default

That will work, just assuming every book title has "The " at the beginning.
If a book title doesn't, for example "Gone with the wind" it will output "
with the wind, The"

--
David Billigmeier


"Brian Synowiec" wrote:

How about this:
Assuming your book names start in A1, and the titles are less than 100
charecters (increase the 100 in the formula if they are longer);put this in
B1 and copy down:

=MID(A1,4,100)&", The"

Brian


"Edye" wrote:

Excel 2003
I have a list of books. About 700 contain a "The" at the beginning. I need
to add ", The" (without quotes) to the end of each one of those book titles
and remove the "The" at the beginning of the title. I recorded a Macro for
it, but each time I use the Macro, it replaces the other cells with the title
of the one which I recorded. Thanks!



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
I was messing arround with the VBA and now I get the macro warning when I open the work book but when... Marc New Users to Excel 2 June 6th 05 08:08 AM
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Using a macro how do I group every sheet within a book? Pank Mehta Excel Discussion (Misc queries) 3 March 17th 05 06:44 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM


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