+ Reply to Thread
Results 1 to 3 of 3

Add X from every numeric value

  1. #1
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Add X from every numeric value

    Hi,

    I wonder if someone can present a VBA (or any other solution) how to browse an entire document (full of text and numbers) and when the selected word is a numeric value (can be 123 or 06) to add X which will be inputted by the user via a Inputbox command.

    Hopefully, such a solution will be capable also to add the same X to a typed Date (to increase the day only in a non date field type)

    It will be nice if the macro will stop at any founded numeric value and ask weather to add or to leave the value intact and move to the next word.

    Any suggestions will be more that appreciated.

    I managed to write a short code but it does not work as expected.

    If X = 3 and the found value is 5 - the result gets to be 53
    Please Login or Register  to view this content.
    Thanks, Elm
    Last edited by ElmerS; 04-19-2010 at 02:46 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Add X from every numeric value

    Perhaps:

    Please Login or Register  to view this content.
    Might be worth having an escape clause if X is 0.

    The above would only partially work with "numeric-alphas" rather than "alpha-numerics" - eg 123test would be found whereas test123 would not (Val being 0) - not clear what your requirements are on that front

    The dates - based on my v limited testing - it would seem each part of the date is interpreted as being a different word - treating as a date serial would warrant testing 5 words (delimiter pending) and testing resulting string for IsDate - handling appropriately.

    I have v little experience using Word object model - others are far more proficient and may have a better alternative to the above (RegExp perhaps).

  3. #3
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Add X from every numeric value

    This should do it.

    Thanks, Elm

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1