+ Reply to Thread
Results 1 to 4 of 4

Array Copying Help

  1. #1
    Forum Contributor
    Join Date
    02-13-2017
    Location
    Durham
    MS-Off Ver
    2013
    Posts
    126

    Array Copying Help

    Hi All,

    I have the following code:

    Please Login or Register  to view this content.

    It simply looks at my excel book and searches for the sheets AFTER the 3 named at the beginning. Once found it then proceeds to copy the column I've asked it to search (Minus the title of the column) and past it into another workbook.

    It works fine - However an issue occurs from time to time.

    If There are lets say '5' sheets after the named 3 and 4 of them have the Column BUT no data under it - my code proceeds to simply copy the column header for those sheets and past it instead. Is there anywhere in my code that would ask it to do so? I cannot see the issue at all.

    Thanks
    Last edited by Scoobster_doo; 03-23-2017 at 12:10 PM.

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Array Copying Help

    Macro sets end range for copying by determine lastrow i.e.
    Please Login or Register  to view this content.
    Then macro copies range from row 3 to lastrow as you wish to avoid copy headings
    Please Login or Register  to view this content.
    but if the is no data in row 3 and the rows below the lastrow will be 2 assuming headings in row 1 and 2 and macro will copy row 2 and 3 in the specified column. Row 2 will contain heading and row 3 is empty so this what gets copied.

    Alf

    You need to test if lastrow is less than 3 and skip the copy operation in this case

  3. #3
    Forum Contributor
    Join Date
    02-13-2017
    Location
    Durham
    MS-Off Ver
    2013
    Posts
    126

    Re: Array Copying Help

    Alf,

    That makes perfect sense! It's been running me ragged . I shall write up a test for last row.

    Thanks

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Array Copying Help

    You are welcome.

    Thanks for feedback and rep

    Alf

+ 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. VBA with Array not copying all the columns.
    By excellearner121 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2014, 04:49 AM
  2. [SOLVED] Copying array formula to last row using VBA.
    By Folshot in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-02-2013, 12:20 PM
  3. [SOLVED] Copying an Array
    By UNAB in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-26-2013, 08:16 PM
  4. Copying Array
    By yogeshmaney in forum Excel General
    Replies: 1
    Last Post: 02-26-2010, 03:55 AM
  5. Copying from an array conditionally
    By robhargreaves in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-06-2007, 12:59 PM
  6. Copying an Array
    By BDH in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-21-2006, 12:15 AM
  7. Copying an Array Formula
    By montagu in forum Excel General
    Replies: 1
    Last Post: 07-15-2005, 02:30 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