Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Attach code | Excel Worksheet Functions | |||
NEED VB TO REMOVE INITIALS FROM A NAME | Excel Programming | |||
NEED VB TO REMOVE INITIALS FROM A NAME | Excel Programming | |||
code to attach files | Excel Programming | |||
How do I properly attach vba code to a workbook | New Users to Excel |