+ Reply to Thread
Results 1 to 5 of 5

Excel VBA - Word to search for part of a word and replace full word

  1. #1
    Registered User
    Join Date
    12-13-2016
    Location
    bradford
    MS-Off Ver
    2010
    Posts
    10

    Excel VBA - Word to search for part of a word and replace full word

    Hello there,

    (post changed if your wondering i you have seen it before)

    I have the following code that is mostly from google as a starting point:

    Please Login or Register  to view this content.
    however i cannot determine a way to use the code to replace an entire section of text, rather than just a part of it: e.g searching 4500 and replacing it with 45001111 if the text to replace is 4500xxxx

    45001111xxxx

    were i was wondering if it can be replaced as just:

    45001111

    hope that makes sence? any thoughts?
    Attached Files Attached Files
    Last edited by charlie543; 12-23-2016 at 06:59 PM. Reason: moderator correction

  2. #2
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Not your usual vba to replace word problem

    If you find a solution to your problem, I'll use it for an application I'm working on as well.

    Unfortunately, I'm not at the point in my project where I'm working on this, but if I do work towards that and solve it, I'll post my results in the 1-2 month timeframe.

    I've found that VBA doesn't work with Word nearly as well as Excel or Database files.
    Last edited by joe31623; 12-22-2016 at 04:36 PM.
    <---If my answer helped, please click *

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,602

    Re: Not your usual vba to replace word problem

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ben Van Johnson

  4. #4
    Registered User
    Join Date
    12-13-2016
    Location
    bradford
    MS-Off Ver
    2010
    Posts
    10

    Re: Not your usual vba to replace word problem

    Quote Originally Posted by protonLeah View Post
    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    erm are you a mod? - i was hoping to change it too :

    excel vba - word to search for part of a word and replace full word.

    is that ok?

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Excel VBA - Word to search for part of a word and replace full word

    Hello charlie543,

    There are more options to the Find method than what you have in your code. Find accepts the use of wildcard characters "*", "?", and "#".

    The asterisk, "*", matches zero or more characters.

    The question mark, "?", matches any single character.

    The pound sign or hashtag, "#", matches any single digit.

    You can also control whether to ignore case, search for a whole or partial word. Below is the amended macro to let you search using a partial match and replace it with the string you specify.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Help with macro to find a specific word and replace the entire cell with the return word.
    By BG1983 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 08-24-2015, 09:40 PM
  2. [SOLVED] Excel macro- Find replace an itallic font word with a regular word?
    By thisisaboutwork in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2013, 01:48 PM
  3. Need help with Excel-to-Word find and replace macro based on word filename
    By EnterTheSerpent in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2013, 12:48 PM
  4. Search and Replace... from Excel to Word
    By Xx7 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-27-2011, 03:05 PM
  5. Replace word in MS Word with varable from MS Excel
    By odo in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-05-2009, 05:18 PM
  6. Replies: 1
    Last Post: 12-20-2005, 10:00 AM
  7. Replies: 5
    Last Post: 09-13-2005, 07:06 AM

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