+ Reply to Thread
Results 1 to 4 of 4

Copying column with merged rows

  1. #1
    Registered User
    Join Date
    09-27-2012
    Location
    Warrington, England
    MS-Off Ver
    Excel 2007
    Posts
    27

    Copying column with merged rows

    I have a simple spreadsheet comprising columns A to F. I want to copy just column D using VBA and copy to another column (as part of a larger macro). Simple so far. However. a number of the rows have the columns merged across all 6 so when I select the column using VBA all the columns are selected and copied. I just need to copy column D. My code is:

    Please Login or Register  to view this content.
    i also tried with FirstRow and LastRow as variables corresponding to the first and last row to be copied but it still didn't work.

    Please Login or Register  to view this content.
    but if I use Record Macro and click on column D at the top, I get
    Please Login or Register  to view this content.
    and this ignores the rows with the merged columns.

    Any suggestions? It would not be practicable to unmerge or delete the rows with the merged columns.

    Thanks in advance.
    Last edited by noclass1980; 02-06-2013 at 09:05 AM. Reason: Additional information added

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Copying column with merged rows

    Do you need to copy the data, or could you just transfer the values?

    For example, this will move the values to column G, and will ignore the merged columns:

    Please Login or Register  to view this content.
    Quote Originally Posted by noclass1980 View Post
    Any suggestions? It would not be practicable to unmerge or delete the rows with the merged columns.
    <Grammar Nazi mode=On>It may not be practical, but it is practicable </GN=Off>

  3. #3
    Registered User
    Join Date
    09-27-2012
    Location
    Warrington, England
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: Copying column with merged rows

    Thanks, that's works fine and copies column D but I now want to select D only. I don't see why the macro recorded method works but the vba way doesn't. Any suggestions?
    Thanks.

  4. #4
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Copying column with merged rows

    No, I couldn't get it to work either, even things like:

    Please Login or Register  to view this content.
    Still selected all of the merged columns.

    So, I suppose the question now is why do you need to select column D? When working with macros it's hardly ever necessary to actually select objects.

+ 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