Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / December 2007

Tip: Looking for answers? Try searching our database.

Excel 2003 Find and Replace

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jr0410 - 02 Dec 2007 20:20 GMT
I have a column of numbers.  Some numbers vary in the number of characters
and some are strickly numbers; others are a mix of numbers and letters.  I
would like to replace those numbers with the same numbers but with
parenthesis around each of them.  How do I do that?
Gord Dibben - 02 Dec 2007 20:27 GMT
Paste a representative sample of your data into a post so's we can have a look.

Gord Dibben  MS Excel MVP

>I have a column of numbers.  Some numbers vary in the number of characters
>and some are strickly numbers; others are a mix of numbers and letters.  I
>would like to replace those numbers with the same numbers but with
>parenthesis around each of them.  How do I do that?
Ron Rosenfeld - 02 Dec 2007 22:12 GMT
>I have a column of numbers.  Some numbers vary in the number of characters
>and some are strickly numbers; others are a mix of numbers and letters.  I
>would like to replace those numbers with the same numbers but with
>parenthesis around each of them.  How do I do that?

If I understand you correctly, you would want the string:

ab12ab33

to change to:

ab(1)(2)ab(3)(3)

This UDF will do that.

To enter the UDF, <alt-F11> opens the VBEditor.  Ensure your project is
highlighted in the Project Explorer window, then Insert/Module and paste the
code below into the window that opens.

To use this function, enter a formula of the type:

=parennums(A1)

If you want different functionality, it's pretty easy to change this.  Post
back.

================================
Option Explicit
Function ParenNums(str As String) As String
Dim re As Object
   Set re = CreateObject("vbscript.regexp")
       re.Global = True
       re.Pattern = "(\d)"
ParenNums = re.Replace(str, "($1)")

End Function
==============================================
--ron

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.