+ Reply to Thread
Results 1 to 3 of 3

Extract a word in the workbook's filename and add this word to another word

  1. #1
    Registered User
    Join Date
    03-22-2016
    Location
    Sweden
    MS-Off Ver
    2010
    Posts
    3

    Extract a word in the workbook's filename and add this word to another word

    Hello,
    Being a newbie, I am looking for a macro that:

    1) Searches the filename of the active workbook for a specific word
    2) Takes the word found in (1) and adds this to another word (with one space between the words)
    3) Prints the two words in uppercase in cell B2 of the workbook "Mainbook.xlsm" (which is already open in the background).

    Example:
    Assume that the specific word in (1) is "morning", "day" or "night"
    Assume the "another" word in (2) is always "time"

    Then, if the filename of the active workbook is, say, "Nowitsmorningagain.xlsm", the end result in cell B2 in "Mainbook.xlsm" should be "MORNING TIME"; or if the filename of the active workbook is, say, "What a beautiful day.xlsm", the end result in cell B2 in "Mainbook.xlsm" should be "DAY TIME"; or finally, if the file name of the active workbook is "Good night.xlsm", the end result in B2 in "Mainbook.xlsm" should be "NIGHT TIME". ( I guess some kind of a loop would be appropriate here).

    As indicated, the filename of the active workbook can be more or less anything (and with no spaces), but the file name will always contain either morning, day or night, i.e. they will never occur together in the file name, only one of them will appear somewhere in the file name. It would be nice to get a message if the filename of the active workbook does not contain morning, day or night.

    Does anyone have any suggestions how to code this simple example? Many thanks in advance!

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Extract a word in the workbook's filename and add this word to another word

    Hi and welcome to the forum. Try something like this...

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 03-24-2016 at 07:49 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    03-22-2016
    Location
    Sweden
    MS-Off Ver
    2010
    Posts
    3

    Re: Extract a word in the workbook's filename and add this word to another word

    Great, many thanks for the quick reply!

+ 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. Replies: 3
    Last Post: 02-16-2016, 11:41 AM
  2. Replies: 2
    Last Post: 04-29-2014, 10:06 AM
  3. Extract last word from a string and next to last word and so on.
    By ejbeckwith in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2013, 08:51 AM
  4. 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
  5. Search for a word in a column and extract the word
    By Abishekar in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-17-2012, 09:30 AM
  6. Export the workbook filename to Word
    By twofootgiant in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-17-2011, 02:28 PM
  7. Extract a text from word and place it en excel or word?
    By Elegidos in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2009, 06:14 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