+ Reply to Thread
Results 1 to 3 of 3

Excel 2007 : Search for word and put formula in different cell.

  1. #1
    Registered User
    Join Date
    08-20-2009
    Location
    Swindon, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Search for word and put formula in different cell.

    Hi,

    I have a Sheet with 3 columns and x number of rows
    The first column contains web addresses, middle one is not important and the third is blank.

    What im trying to make is a macro that will search the first column for part of web address, eg. google and it will paste a specific formula in the third column depending on the result of the search. Also if the first column is empty then the macro will stop.

    So an example is
    Column 1--------Column2-----Column 3
    Google.com--------------------=1+1
    Google.co.uk-------------------=2+2
    Yahoo-------------------------=3+3

    I Have done:

    Cells.Find(What:="google.co.uk", After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
    ActiveCell.Offset(columnOffset:=3).Activate

    But i don't think im going down the right path here....

    Any help would be greatly appreciated. My result will be posted if i manage to figure it out.

    Regards,
    TLeo
    Last edited by TLeo; 08-26-2009 at 08:59 AM.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Search for word and put formula in different cell.

    I would opt for a Select Case approach. I'm not clear on exactly what you want placed into column-3. Do you want the text "1+1", etc.? It makes no sense (to me) to place a formula =1+1, if that is what you intended.

    Adapt as required.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-20-2009
    Location
    Swindon, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Search for word and put formula in different cell.

    Thanks, but im having some trouble with the formula that i want to paste since it contains " within the formula itself.

    The forumula is =IFERROR(MID(A1,SEARCH("q=",A1)+2,SEARCH("&",A1,SEARCH("q=",A1,1))-SEARCH("q=",A1,1)-2),"")

    but when i add the " to the beginning and end i get errors.


    At the moment i have 3 columns of data and in the second column i have search urls (google,yahoo,aol, and others)
    What i want is to extract the search terms from the urls into a fourth column so its easier to see.
    The above URL extracts the google search terms.

    So the point of the macro is to determine if the url is from google, yahoo or another and put the appropriate url into the fourth column so the search terms are displayed.

    Ill add a part of the excel sheet that im using. It will make more sence of what i want.
    Attached Files Attached Files
    Last edited by TLeo; 09-15-2009 at 08:13 AM. Reason: adding a better description

+ 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