+ Reply to Thread
Results 1 to 6 of 6

code to find text, offset 1 column and paste to new workbook not working

  1. #1
    Registered User
    Join Date
    08-08-2010
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2010
    Posts
    85

    code to find text, offset 1 column and paste to new workbook not working

    Hi there

    I'm working with a report that has text and many empty cells. However, periodically the word "Location" appears in column A. I would like to copy what appears next to that word (column B) and paste it in the next empty cell on another sheet under the word "Location".

    Basically, I am searching a report output and trying to make a Database summary of the information onto another tab to make it easier to read, etc.

    I'm struggling with trying to find a match for text in a column though...

    Please Login or Register  to view this content.
    I highlighted in Red where the marco bugs and gives a Runtime 424: Object required error, which I can't seem to solve.

    OK, in the preview it doesn't show. This is the line it stops at:
    Please Login or Register  to view this content.
    I will be going through other columns to capture the other info and paste it as well.

    Thoughts?

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: code to find text, offset 1 column and paste to new workbook not working

    Your code fails because of the .Select on the end, try removing that.

    If all you're trying to do is copy all the column J values to the new sheet for the rows that have "Location" in column A, this is what AUTOFILTER was invented for. This method will filter the first sheet leaving only the rows with "Location" showing, then copy the column J values all at once to the Sheet2 in cell A2. No looping.

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-08-2010
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: code to find text, offset 1 column and paste to new workbook not working

    Hi there!

    I'd thought about autofilter, but the information on the report output page is not in a chart form, so there are lots of empty spaces inbetween the text. The other titles I want to use are also scattered around on the sheet. Luckily each output has the information always in the same column, so for example, "Location" is always column "A", another one is "J" etc. But above and below the target text, there are empty spaces, autofilter won't work. This way why I was trying to use a loop instead.

    :-)

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: code to find text, offset 1 column and paste to new workbook not working

    Please Login or Register  to view this content.
    Last edited by snb; 07-09-2011 at 08:34 AM.



  5. #5
    Registered User
    Join Date
    08-08-2010
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: code to find text, offset 1 column and paste to new workbook not working

    Hi again... autofilter does not work because of all the empty spaces in the column, it just finds blanks underneath... is there any way a loop through the column can work?

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: code to find text, offset 1 column and paste to new workbook not working

    You are mistaken: autofilter works despite any 'empty' cells in the column you are filtering. I fear you didn't test my code.

+ 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