+ Reply to Thread
Results 1 to 5 of 5

Copy variable length data with a twist!

  1. #1
    Forum Contributor
    Join Date
    09-22-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 2019
    Posts
    309

    Copy variable length data with a twist!

    Hi

    I have a worksheet (Team List) in an open workbook (Master) that has a list of formula in column AJ. This list of Formula starts with
    Please Login or Register  to view this content.
    which gives me a line of text. The Code is copied down 101 rows with B2 changing as it goes (B3, B4, B5 etc).

    Not all 101 rows return a result every time and there are no Blank cells (just text or formula) up until column B is empty.

    I'm copying the information from column AJ into column AZ (Starting at AZ4) in another workbook (named Remote) using a button in the Remote workbook.

    I'm using the PasteSpecial xlpasteValues code into AZ and only the text rows appear (say 20 rows) with all the other rows apparently Blank. However, if I write a =COUNTA(AZ:AZ) formula it returns 101, suggesting that there is actually something hidden in the remaining 81 rows. This is then messing up the Code below that is scrolling through the list in AZ to return data from several worksheets (names in AZ).

    (The twist is that the Code is looking at the open Master workbook which can have a variable name so is not identified.)

    The complete Code in the Remote workbook calls for data from several different places in the worksheets listed at AZ, but it's only this one that causes an issue because I later search the list and the search code crashes because it seems to see something in the Blank cells. (See below)

    I've attempted to copy just the rows with values in from AJ using the commented out code on Line 3,
    Please Login or Register  to view this content.
    without success as this gives a 1004 Application or Object not defined error.

    Where am I going wrong please?

    The complete Code is as follows;
    Please Login or Register  to view this content.
    The part of the Code that fails is …..

    Please Login or Register  to view this content.

    The search code that works down the list in AZ is

    Please Login or Register  to view this content.
    Many thanks in advance as I should be able to do this by now and it's really bugging me!!

    Frankie

  2. #2
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: Copy variable length data with a twist!

    Not sure I understood everything, but try something like this...
    Please Login or Register  to view this content.
    Best Regards,
    Maras.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Copy variable length data with a twist!

    Using the .Find method should copy the rows with text excluding the formulas in the bottom rows that return a null string

    Please Login or Register  to view this content.

    You can also test if the pasted cell has text like this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,004

    Re: Copy variable length data with a twist!

    I'm using the PasteSpecial xlpasteValues code into AZ and only the text rows appear (say 20 rows) with all the other rows apparently Blank. However, if I write a =COUNTA(AZ:AZ) formula it returns 101, suggesting that there is actually something hidden in the remaining 81 rows.
    I think you're right, the formula does return something even the cells look empty.
    This article might be useful for you:
    https://excel.tips.net/T002814_Retur...ank_Value.html

    to deal with the problem, try using ".value = .value" to copy paste values between 2 ranges, something like this:
    Replace this:
    Please Login or Register  to view this content.
    with this:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    09-22-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 2019
    Posts
    309

    Re: Copy variable length data with a twist!

    Thanks one and all that's awesome! Apologies if the post was a bit confusing. I probably shows where my brain was at the time!!

+ 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. [SOLVED] Copy & Paste Variable data length into summary sheet after last used row
    By Roshan.Shakya in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-05-2019, 11:53 AM
  2. [SOLVED] Copy & Paste variable length row using VBA
    By NatalieW12 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-04-2019, 04:38 PM
  3. [SOLVED] Copy & Paste Variable data length into summary sheet after last used row
    By spyac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-14-2018, 11:31 AM
  4. [SOLVED] Copy and Paste a Variable-Length Range
    By andrewc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2015, 12:46 PM
  5. [SOLVED] copy range with variable length
    By Coleman34 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2014, 01:07 PM
  6. Find/Copy Variable length range
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-06-2006, 03:55 PM
  7. copy variable length cells to a new sheets
    By Souris in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2005, 01:05 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