+ Reply to Thread
Results 1 to 13 of 13

Loop through all non empty columns and rows and copy each N row

  1. #1
    Forum Contributor
    Join Date
    12-24-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    153

    Loop through all non empty columns and rows and copy each N row

    Dear Friends,

    I am new to VBA and need your support. I have big set of data and i should somehow accelerate my work. Could plz somebody help with code doing following: loop through all non-empty columns in Activesheet until last row in each column (number of rows and columns can vary) and during looping to copy each N row to other "Sheet2" for example?! By another words: Number of columns in Sheet2 should be the same, but number of rows in N times less...

    I will be appreciate for any input File example is attached.

    Regards,
    ISMI
    Attached Files Attached Files

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Loop through all non empty columns and rows and copy each N row

    What is an "N" row - there are no data in column N
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    12-24-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    153

    Re: Loop through all non empty columns and rows and copy each N row

    It will be a number, which can vary (you can use eg. 3 for testing of macro). Number of columns in both sheets should be the same. In that case macro should copy to sheet2: row(1) then row(4) then row (7) and next until last one. I hope it helps you

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Loop through all non empty columns and rows and copy each N row

    I don't understand the rows all start with a date then are filled with numbers

  5. #5
    Forum Contributor
    Join Date
    12-24-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    153

    Re: Loop through all non empty columns and rows and copy each N row

    Yea, it is true (time by x-axis, and 3 temperatures by y-axis). In that case macro should copy data to Sheet2 with the same Number Format. Is it possible?

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Loop through all non empty columns and rows and copy each N row

    I don't get it can you post an example of what you want?

  7. #7
    Forum Contributor
    Join Date
    12-24-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    153

    Re: Loop through all non empty columns and rows and copy each N row

    Ok, sorry for confusing...once again...I have initial sheet with data in many columns (in each column number of row can vary and can be up to 30000). For example: assume that we have 3 columns (A, B, C) with 9000 non-empty rows in each. Lets N=3, so macro should copy data in column A from: row(1)...row(4)...row(7)...row(8997)...row(9000) into Sheet 2 in the same column "A" (but in row1, row2, row3...row3000).

    If there is last value in column A, then go to cell B1 and repeat the same procedure until cell B9000, then repeat the same for range C1:C9000. If next column is empty, then stop a macro and do not copy anything.

    I hope it will helps and you will get a clear picture in your mind. Thank in advance!

    P.S: during coping please keep initial "Number Format".

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Loop through all non empty columns and rows and copy each N row

    You want every Nth row?

    Going to work now - be back later - but not sure I can help

  9. #9
    Forum Contributor
    Join Date
    12-24-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    153

    Re: Loop through all non empty columns and rows and copy each N row

    Yep, every Nth row. Any help is help

  10. #10
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,285

    Re: Loop through all non empty columns and rows and copy each N row

    Not sure what you want perhab
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    12-24-2016
    Location
    London
    MS-Off Ver
    2013
    Posts
    153

    Re: Loop through all non empty columns and rows and copy each N row

    Awesome! Except small typo, everything works:
    Please Login or Register  to view this content.
    Thank you very much!

  12. #12
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,285

    Re: Loop through all non empty columns and rows and copy each N row

    Glad to help
    "ThankyouFor Attention * And Your Help!!"

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Loop through all non empty columns and rows and copy each N row

    Thanks for the rep!

+ 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. copy values from columns to rows while skipping empty columns...
    By EricCy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-10-2016, 06:20 AM
  2. Replies: 1
    Last Post: 02-11-2015, 07:47 AM
  3. [SOLVED] LOOP to copy columns/rows
    By yubluff in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 08-26-2014, 03:58 PM
  4. Delete Empty Rows and empty columns from the word table
    By mvneema in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2014, 10:51 AM
  5. Need help with a macro to copy rows into two columns, ignoring empty cells.
    By ukeleleperson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-24-2014, 04:51 AM
  6. Replies: 3
    Last Post: 03-27-2013, 03:58 PM
  7. [SOLVED] Loop to copy rows from two worksheets until reaching empty row
    By Brukernavn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2013, 05:06 AM

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