+ Reply to Thread
Results 1 to 13 of 13

Search for string, copy adjacent cell

  1. #1
    Registered User
    Join Date
    07-28-2014
    Location
    Kentucky, USA
    MS-Off Ver
    2007
    Posts
    10

    Search for string, copy adjacent cell

    Here is the brief summary of the problem I've run into, and am hoping one of the gurus here can hlep with.

    I am working with workbook Rollup, which has an area to display a total cost generated on multiple cells and multiple spreadsheets from workbook Costs.
    What I am trying to do is write a function in a cell in the main spreadsheet of workbook Rollup, that will do a search for the word "Diff" in all of the spreadsheets in workbook Costs and then aquire the data from the cell to the right of the "Diff" cell, and total them all together in the cell in Rollup.

    The problem is, the number of items before the "Diff" cell changes, so "Diff" is not always located in the same row number which has put it outside of my Excel skills.

    Not sure how to make that any more clear...sorry.

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Search for string, copy adjacent cell

    Can you post an example? You would likely be able to work without VBA using some intelligent formulas in the worksheet. There are VBA trick to do this also - either way, without an example it's hard to help
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    07-28-2014
    Location
    Kentucky, USA
    MS-Off Ver
    2007
    Posts
    10

    Re: Search for string, copy adjacent cell

    Quote Originally Posted by GeneralDisarray View Post
    Can you post an example? You would likely be able to work without VBA using some intelligent formulas in the worksheet. There are VBA trick to do this also - either way, without an example it's hard to help
    Here is a mockup of the workbook I need to pull data from. As you can see, the cell "Diff" is in a different row for each spreadsheet due to the number of items.
    I need to pull the numbers from the cell to the right of "Diff" on all of the spreadsheets in that workbook and total them up in a cell in a different workbook.

    Book1.xlsx

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Search for string, copy adjacent cell

    You could probably get around VB with named ranges for the cells, but this is easy to VBA.


    Please Login or Register  to view this content.

    That code is included in the attached example (See the new sheet I added for the value). Can you edit that for your needs? NOTE: I forgot to pass in the colOffset (highlighted in red) In the attachment I hard-coded the offset to (0,1)... you can fix it
    Attached Files Attached Files
    Last edited by GeneralDisarray; 07-28-2014 at 02:58 PM.

  5. #5
    Registered User
    Join Date
    07-28-2014
    Location
    Kentucky, USA
    MS-Off Ver
    2007
    Posts
    10

    Re: Search for string, copy adjacent cell

    I'm not very strong with VB. This code works like a dream in the example file. I will be using it in work book "Rollup", to execute its job in regards to data in workbook "Costs"

  6. #6
    Registered User
    Join Date
    07-28-2014
    Location
    Kentucky, USA
    MS-Off Ver
    2007
    Posts
    10

    Re: Search for string, copy adjacent cell

    Quote Originally Posted by omaolain View Post
    I'm not very strong with VB. This code works like a dream in the example file. I will be using it in work book "Rollup", to execute its job in regards to data in workbook "Costs"
    Any guidance on how to adjust the code to work and place the total value in spreadsheet Rollup, but aquire all of the data it is searching for from spreadsheet Costs?

  7. #7
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Search for string, copy adjacent cell

    Let me know a little more about what you are doing. First, you have to pull information from a number of worksheets in a single workbook, but do you need that number delivered to the same workbook or another one?

  8. #8
    Registered User
    Join Date
    07-28-2014
    Location
    Kentucky, USA
    MS-Off Ver
    2007
    Posts
    10

    Re: Search for string, copy adjacent cell

    The data will be collected and pulled from all the spreadsheets in the workbook "Costs" (the code you wrote works wonderfully for that), and needs to be delivered in workbook "Rollup" which is the part I'm struggling with.
    I can follow some of it, but VB is most definitely not my strong suite.

  9. #9
    Registered User
    Join Date
    07-28-2014
    Location
    Kentucky, USA
    MS-Off Ver
    2007
    Posts
    10

    Re: Search for string, copy adjacent cell

    Quote Originally Posted by omaolain View Post
    The data will be collected and pulled from all the spreadsheets in the workbook "Costs" (the code you wrote works wonderfully for that), and needs to be delivered in workbook "Rollup" which is the part I'm struggling with.
    I can follow some of it, but VB is most definitely not my strong suite.
    Any further guidance on how to create this particular change?
    I've played around with the code trying to make it work, but all I manage to do is take it from functioning to nonfunctioning.

  10. #10
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Search for string, copy adjacent cell

    Can you post what you've done? Maybe I can get it back on track for you. The macros provided were only going to work within a single excel file - do you need the value calculated on one file (costs) and delivered to another(rollup)?

  11. #11
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Search for string, copy adjacent cell

    Try this plan of attack:

    In the Cost workbook, create a code module (ask how if you need it).

    In that module, Paste this:

    Please Login or Register  to view this content.
    Somewhere in the cost workbook, put this into a cell as a formula: =sumdiff_forRollup()
    That will capture the value you are looking for and you'll be able to pass that value to the other file (rollup workbook) by just referencing that cell. Call this cell Tot_Diff for the rest of this comment.


    Now, open the rollup file. Select the cell in which you want to place the value, type = to start a formula, then go to the Cost file and select the Tot_Diff cell we just created. Then press enter and you can close the Cost workbook.

    That should do it.

  12. #12
    Registered User
    Join Date
    07-28-2014
    Location
    Kentucky, USA
    MS-Off Ver
    2007
    Posts
    10

    Re: Search for string, copy adjacent cell

    GeneralDisarray,

    Thnaks for your help with this, I actually got it working not long after my last post. Again, I really appreciate the help you gave me on this.

  13. #13
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Search for string, copy adjacent cell

    No problem Glad to hear you got it working.

+ 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] Search value in cells and copy adjacent value to specific cell
    By venkatakrishna in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-02-2014, 11:21 AM
  2. Search for a text string and return adjacent cell value for each match
    By ral8088 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-21-2013, 09:55 AM
  3. [SOLVED] VBA for searching string in a column and copy rows depending on string in adjacent cell
    By xprakash in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-20-2013, 05:58 AM
  4. Search for a string value and make adjacent cell True
    By ChuckT in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-28-2012, 03:46 PM
  5. Search for Word and Copy Adjacent Cell(s)
    By BrittanyK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-09-2011, 04:05 PM

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