3

Is it possible to prevent data being pasted into the hidden columns in one copy/paste movement rather than having to copy/paste multiple times?

2
  • I have looked for that for years, I think "No, it's not possible". My workaround is to sort the target area so my target lines are all next to each other. Cumbersome, yes.
    – Aganju
    Commented Mar 25, 2019 at 22:25
  • 1
    Hidden the same columns in the first Worksheet and then copy the whole Worksheet to the second one.
    – Lee
    Commented Mar 26, 2019 at 2:53

1 Answer 1

0

I would like to suggest comparatively the best & fastest method to Paste data by skipping hidden Columns.

Before Copy & Paste:

enter image description here

After Paste:

enter image description here

N.B. As you can find the Macro has skipped the hidden Column H, while Paste data from Range A1:C9.

How it works:

  • Hide Column/Columns, with this post Col H is hidden.

  • Either Right Click the Sheet Tab & from poped up menu Click View Code, or press Alt+F11, to get the VB editor.

  • Copy & Paste this VBA code(Macro) as Standard Module then RUN the Macro TestCopyPaste.

    Sub TestCopyPaste()
    
    CopySkippingHidden ActiveSheet.Range("A1:C9"), _
      ActiveSheet.Range("G1")
    
      End Sub
    

Sub CopySkippingHidden(rngToCopy As Range, pasteStart As Range)

    Dim c As Range


    For Each c In rngToCopy.Columns

        Do While pasteStart.EntireColumn.Hidden
            Set pasteStart = pasteStart.Offset(0, 1)
        Loop
        c.Copy pasteStart

        Set pasteStart = pasteStart.Offset(0, 1)

    Next c

End Sub
  • ActiveSheet.Range("A1:C9") & ActiveSheet.Range("G1") are editable.
  • Where A1:C9 is Source to be copied, and G1 is Target to Paste copied Data.
  • You may adjust cell references/Data Range also.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .