Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default NEED VB TO REMOVE INITIALS FROM A NAME

DEAR ALL
I have in excel-97, some 3 thou odd names. But the names have
initials like A.R.S.CHARLIE; K.T.WHITE; B.PHILIPS and so on. Can you
pls sugest a VB code so that it goes through each cell and removes the
initials and adds it to the end of the name by giving a space -like
CHARLIE A.R.S; WHITE K.T; PHILIPS B. Pls guide
me.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default NEED VB TO REMOVE INITIALS FROM A NAME

Public Sub FixNames()
Dim rng As Range
Dim rngToFix As Range

On Error Resume Next
Set rngToFix = Range(Range("A2"), _
Cells(Rows.Count, "A").End(xlUp)).SpecialCells(xlCellTypeConstan ts)
On Error GoTo 0

If Not rngToFix Is Nothing Then
For Each rng In rngToFix
rng.Value = ReverseName(rng)
Next rng
End If
End Sub

Private Function ReverseName(ByVal rng As Range) As String
Dim lng As Long

ReverseName = rng.Value
lng = InStrRev(rng.Value, ".")
If lng 0 Then
ReverseName = Trim(Mid(rng.Value, lng + 1, 255)) & _
" " & Left(rng.Value, lng)
End If
End Function
--
HTH...

Jim Thomlinson


"CAPTGNVR" wrote:

DEAR ALL
I have in excel-97, some 3 thou odd names. But the names have
initials like A.R.S.CHARLIE; K.T.WHITE; B.PHILIPS and so on. Can you
pls sugest a VB code so that it goes through each cell and removes the
initials and adds it to the end of the name by giving a space -like
CHARLIE A.R.S; WHITE K.T; PHILIPS B. Pls guide
me.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default NEED VB TO REMOVE INITIALS FROM A NAME

Jim,

InStrRev was not introduced until Excel 2000. Asker is using Excel 97.

Kevin

"Jim Thomlinson" wrote:

Public Sub FixNames()
Dim rng As Range
Dim rngToFix As Range

On Error Resume Next
Set rngToFix = Range(Range("A2"), _
Cells(Rows.Count, "A").End(xlUp)).SpecialCells(xlCellTypeConstan ts)
On Error GoTo 0

If Not rngToFix Is Nothing Then
For Each rng In rngToFix
rng.Value = ReverseName(rng)
Next rng
End If
End Sub

Private Function ReverseName(ByVal rng As Range) As String
Dim lng As Long

ReverseName = rng.Value
lng = InStrRev(rng.Value, ".")
If lng 0 Then
ReverseName = Trim(Mid(rng.Value, lng + 1, 255)) & _
" " & Left(rng.Value, lng)
End If
End Function
--
HTH...

Jim Thomlinson


"CAPTGNVR" wrote:

DEAR ALL
I have in excel-97, some 3 thou odd names. But the names have
initials like A.R.S.CHARLIE; K.T.WHITE; B.PHILIPS and so on. Can you
pls sugest a VB code so that it goes through each cell and removes the
initials and adds it to the end of the name by giving a space -like
CHARLIE A.R.S; WHITE K.T; PHILIPS B. Pls guide
me.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default NEED VB TO REMOVE INITIALS FROM A NAME

You are correct. Thanks for catching that. It has been too long since I
worked in 97...
--
HTH...

Jim Thomlinson


"Kevin Jones" wrote:

Jim,

InStrRev was not introduced until Excel 2000. Asker is using Excel 97.

Kevin

"Jim Thomlinson" wrote:

Public Sub FixNames()
Dim rng As Range
Dim rngToFix As Range

On Error Resume Next
Set rngToFix = Range(Range("A2"), _
Cells(Rows.Count, "A").End(xlUp)).SpecialCells(xlCellTypeConstan ts)
On Error GoTo 0

If Not rngToFix Is Nothing Then
For Each rng In rngToFix
rng.Value = ReverseName(rng)
Next rng
End If
End Sub

Private Function ReverseName(ByVal rng As Range) As String
Dim lng As Long

ReverseName = rng.Value
lng = InStrRev(rng.Value, ".")
If lng 0 Then
ReverseName = Trim(Mid(rng.Value, lng + 1, 255)) & _
" " & Left(rng.Value, lng)
End If
End Function
--
HTH...

Jim Thomlinson


"CAPTGNVR" wrote:

DEAR ALL
I have in excel-97, some 3 thou odd names. But the names have
initials like A.R.S.CHARLIE; K.T.WHITE; B.PHILIPS and so on. Can you
pls sugest a VB code so that it goes through each cell and removes the
initials and adds it to the end of the name by giving a space -like
CHARLIE A.R.S; WHITE K.T; PHILIPS B. Pls guide
me.


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
IF Statement to input initials peg84[_2_] Excel Discussion (Misc queries) 2 February 7th 08 12:47 PM
Need Period After Initials Susan Excel Worksheet Functions 21 May 15th 07 09:45 PM
initials + increment [email protected] Excel Programming 6 July 6th 06 10:44 AM
How to pluck out initials of a 2 or 3 word name Craig Brody Excel Worksheet Functions 1 September 9th 05 03:59 PM
Returning User Initials Kelly[_3_] Excel Programming 10 August 11th 03 07:07 PM


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