+ Reply to Thread
Results 1 to 8 of 8

Select Cells with Data ONLY, Copy & Offset! <VBA>

  1. #1
    Registered User
    Join Date
    04-26-2013
    Location
    LA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Select Cells with Data ONLY, Copy & Offset! <VBA>

    I've been searching everywhere for this but still can't find anything that works..

    I have a series of text data in Column Y in every other row (Row 3, 5, 7, and so on) which needs to be copied and pasted 1 row down, and 21 cells to the left. (Offset(1,-21) is correct in this case?) I need this action to continue until the very last data in Column Y.

    This is my first attempt at VBA, so the code below is the only thing I have so far..

    Please Login or Register  to view this content.
    This code itself does the job, but I'd need to copy&paste this code for 1000+ cells that need to be copied.. ><

    Does anyone here have an easy quick solution for this?

    Thank you so much in advance!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Select Cells with Data ONLY, Copy & Offset! <VBA>

    Hello arikoloshio,

    Welcome to the Forum!

    This macro will start at Y3 and go down to the last cell with data in it in "Y". It will copy every other row (3,5,7,etc.) to an offset of (1, -21).
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-26-2013
    Location
    LA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Select Cells with Data ONLY, Copy & Offset! <VBA>

    Thank you so much for such a quick response, Leith!

    I finally got to try out the code, and unfortunately, an error popped out, saying that the code below needs to be "debugged."

    Please Login or Register  to view this content.
    I apologize for my lack of familiarity in advance, but if you could kindly walk me through how to fix this issue, I'd greatly appreciate it!

    Thank you so much once again.

  4. #4
    Registered User
    Join Date
    04-26-2013
    Location
    LA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Select Cells with Data ONLY, Copy & Offset! <VBA>

    My apology - but one thing I forgot to point out that the data contained in Row "Y" are text, not value. This may be the reason why this code is not working for me...

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Select Cells with Data ONLY, Copy & Offset! <VBA>

    Hello arikoloshio,

    After looking at the code I posted, there is typo. The is no object Rnage. It should be Range. Here is the corrected code.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-26-2013
    Location
    LA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Select Cells with Data ONLY, Copy & Offset! <VBA>

    Thank you for the quick response once again.

    I actually noticed that typo beforehand, but even after I fixed the typo, it still gave me a error for the highlighted section below:

    Please Login or Register  to view this content.
    I feel like this may be due to the fact that the Column Y has all text data, and not value. Could this be the reason why? If so, how do I go about fixing it?

    Thank you again in advance and I apologize for the confusion.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Select Cells with Data ONLY, Copy & Offset! <VBA>

    Hello arikoloshio,

    In that case, you will need to post your workbook.

    To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.

    File Manger Picture

  8. #8
    Registered User
    Join Date
    04-26-2013
    Location
    LA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Select Cells with Data ONLY, Copy & Offset! <VBA>

    Sample Doc_AI.xls

    Thank you for the kind instruction!

    I need the odd data in row Y to an offset of (1, -21). For example, I need Y3 to be copied to D4, Y5 to copied to D6, etc. I need this to loop until it reaches the last data in row Y, starting at cell Y3. Please note that data in row Y are text data, not numeric.

    Thank you again

+ 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