• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Hidden columns must stay hidden.

Hello Ninjas:
I have a table with 20 columns. I hide 2 columns and copy the data to another location.
Upon pasting, even the hidden 2 columns r visible.
Is there a way that the hidden columns remain hidden..??
Thank u.
 
Just select the columns you want to copy, press f5 function key, special & select visible cell only, now copy your data & when you past it, the details of the hidden column will not be pasted.
 
Hi James ,

I do not know , but logically thinking about it , the source columns being hidden or not , should not affect the destination columns ; as Srinidhi has mentioned the copying process has two possibilities viz. you copy all cells , both visible and hidden , or you copy only the visible cells. But if you want that after copying , the columns which were hidden in the source should also be hidden in the destination , I don't think this is possible.

Narayan
 
Hi, James Perry!

Give a look at the uploaded file. It has 2 macros with the below code. If you run them, you'll notice that copying a range with hidden columns will hide the target area as well.
Code:
Option Explicit
 
Sub CopyHiddenGetHidden()
    Sheets("Hoja1").Columns("B:C").Hidden = True
    Sheets("Hoja1").Columns("A:D").Copy Sheets("Hoja2").Range("A1")
    ActiveSheet.[A1].Select
End Sub
 
Sub ResetSourceAndTargetToVisible()
    Sheets("Hoja1").Columns("A:D").Hidden = False
    With Sheets("Hoja2").Columns("A:D")
        .Hidden = False
        .Cells.ClearContents
    End With
    ActiveSheet.[A1].Select
End Sub
Does this help?

Regards!
 

Attachments

  • Hidden columns must stay hidden. (for James Perry at chandoo.org).xlsm
    15.7 KB · Views: 2
Back
Top