+ Reply to Thread
Results 1 to 4 of 4

Find a Specific Column Title, Copy the corresponding (varying data) and Paste

  1. #1
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Find a Specific Column Title, Copy the corresponding (varying data) and Paste

    Hopefully the title is specific enough....

    So I'm trying to write code to search through a file I've loaded, which will never be the same in terms of data (width, length, whats actually in it). I want it to find the title of a column of data, copy the title all the way to the last row of data for that column and then paste it into another sheet of the workbook. I've tried many different ways of searching, copying, pasting but I can never get it to go past just finding the title and copying/pasting only the title into the next spreadsheet. In the following code I've specified a column to pull the data from but I am unsure if it will always be the same column. This is my nth time of rewriting multiple different codes, unfortunately I haven't saved any of my previous attempts (you live and learn) so this one is just basic....anyone have any ideas?

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: Find a Specific Column Title, Copy the corresponding (varying data) and Paste

    Hi Sperry,

    "One way to do that is simply find the name of the column. Select till bottom, copy it, then navigate to the sheet which you wish to paste and paste it there." - I know that you're aware of how to do it, but I actually gave you the instructions of how to make it work in VBA. There is a "Record Macro" button under Developer tab in the ribbon. If you can't find, simply go to options and make it view from there. After hitting it, simply do the same instructions as told, and the macro will be recorded. Just make right changes to make the recorded macro a consistent macro.

    Well, for your query. Below is the code. Please Note, the code is not tested, but that's how I do these operations in my reports. I considered the text you're trying to search, "Text_To_Find" is hard-coded. Also the cell in sheet2 from which you want to paste the values is starting from B2.

    Note: If you want you can actually give a cell reference for the Search Text - telling the macro to take the text from the specified cell in the sheet to make the search. Then you just have to make sure you put the right value in "After:=" parameter so that it doesn't take the same cell into consideration while searching - if its in the same sheet.

    Please Login or Register  to view this content.
    cOdEsLiZeR - Back after a long break.. Let's sLiZe some more cOdEs!!

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    What's the name of the title you want to find?

    Which row will it be in?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Find a Specific Column Title, Copy the corresponding (varying data) and Paste

    Sorry for the delayed response. Thank you! This works perfectly. I keep forgetting about the macro button and pulling examples from there. I'm still slowly learning how to navigate this part of excel/VB. Thank you again though! I've been able to adapt this to a few things in my code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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