+ Reply to Thread
Results 1 to 10 of 10

copy hidden columns too

  1. #1
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    206

    copy hidden columns too

    Here is a piece of code i was given that will copy an entire row but not the hidden columns. What changes would I need to make to make it copy the hidden columns as well. Thanks.


    Please Login or Register  to view this content.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: copy hidden columns too

    Hi, backyardfun,

    copying the visible range
    Please Login or Register  to view this content.
    This should copy the full range
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    I added a With-Statement in the upper part of the code.

    Ciao,
    Holger
    Last edited by HaHoBe; 12-29-2013 at 06:08 AM.
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    206

    Re: copy hidden columns too

    I get a compile error, expected end with.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: copy hidden columns too

    Hi, backyardfun,

    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    206

    Re: copy hidden columns too

    It does not give me an error but it is not copying and pasting all of my data. It is pasting the headers in row 2 beginning in column B on "buildlist" sheet. I removed the +1 for the columns which fixed that part. Below, I included the code that comes right before the code you provided me. This code queries the rows to be copied that meet the date. This data resides in rows 3-X with a header in line 2. I need it to copy all rows and all hidden columns that meet that date. Thanks.



    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: copy hidden columns too

    Hi, backyardfun,

    maybe attach a sample workbook for testing instead of revealing more code with named ranges.

    Ciao,
    Holger

  7. #7
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    206

    Re: copy hidden columns too

    [Here is a spreadsheet and my current code in macro Test. As you can see, I unhide rows but do not want to have to do that. Thanks a million!
    Attached Files Attached Files

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: copy hidden columns too

    Hi, backyardfun,

    the title of this thread is quite irritating as any hidden columns are made visible in the course of the macro before copying and hidden again at the end.
    Please Login or Register  to view this content.
    Code works on your sample with Excel2013 on my local system.

    Ciao,
    Holger

  9. #9
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    206

    Re: copy hidden columns too

    I know that the current one works but I do not want to have to unhide and hide the columns. The columns that need to be visible are always changing and I do not want to have to constantly change the column values in the macro.

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: copy hidden columns too

    Hi, backyardfun,

    maybe just take a second to reflect on what the command SpecialCells(xlCellTypeVisible) does or look it up in the VBA-Help. You would need a different approach by creating a new range object based on looping thorugh the visible cells in the criteria column as only that would allow the whole area of a row to be added to the range to copy.

    And this to my opinion is an excellent example of the advantages of the Advanced filter over the Autofilter and all it´s limitations.

    Ciao,
    Holger

+ 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. Excel VBA Copy Operation (with Hidden Columns in-between)
    By Tejas.T in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-10-2013, 11:00 PM
  2. Replies: 0
    Last Post: 09-13-2012, 11:10 AM
  3. All of sudden Copy is including hidden columns
    By finny388 in forum Excel General
    Replies: 9
    Last Post: 09-28-2011, 03:08 PM
  4. Replies: 2
    Last Post: 04-04-2006, 08:25 AM
  5. [SOLVED] COPY - *want* to include hidden columns
    By Eric in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-26-2005, 09: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