Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default PLS SUGEST VB CODE TO REMOVE INITIALS FROM NAME AND ATTACH IT


D/RON
If u find it troublesom to explain at least let me know some links where i
can read up this """"""Set oRegex = CreateObject("VBScript.Regexp")""" etc.
Eagerly awaiting a brief explanation.
with rgds/captgnvr

"Ron Rosenfeld" wrote:

On Thu, 19 Jul 2007 21:54:05 -0400, Ron Rosenfeld
wrote:

=====================================
Option Explicit
Sub MoveInit()
Dim c As Range
Dim oRegex As Object
Dim oMatchCollection As Object
Dim i As Long
Const sPattern As String = "(([A-Z]\.\s?)*)(\w+)"

Set oRegex = CreateObject("VBScript.Regexp")
oRegex.Global = True
oRegex.ignorecase = False
oRegex.Pattern = sPattern

For Each c In Selection
c.Offset(0, 1).ClearContents
c.Offset(0, 1).Value = oRegex.Replace(c.Text, "$3 $1")
Next c
End Sub


Superfluous lines removed

=====================================
Option Explicit
Sub MoveInit()
Dim c As Range
Dim oRegex As Object
Const sPattern As String = "(([A-Z]\.\s?)*)(\w+)"

Set oRegex = CreateObject("VBScript.Regexp")
oRegex.Global = True
oRegex.ignorecase = False
oRegex.Pattern = sPattern

For Each c In Selection
c.Offset(0, 1).ClearContents
c.Offset(0, 1).Value = oRegex.Replace(c.Text, "$3 $1")
Next c
End Sub
================================

--ron

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
Attach code MAX Excel Worksheet Functions 5 March 16th 09 11:11 PM
NEED VB TO REMOVE INITIALS FROM A NAME CAPTGNVR Excel Programming 4 July 18th 07 12:04 AM
NEED VB TO REMOVE INITIALS FROM A NAME CAPTGNVR Excel Programming 3 July 17th 07 11:48 PM
code to attach files Chad Excel Programming 7 April 14th 07 09:24 PM
How do I properly attach vba code to a workbook DrKilbert New Users to Excel 2 March 24th 05 10:39 PM


All times are GMT +1. The time now is 05:52 AM.

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"