Solved

MS Excel - Selected Copy Paste

Posted on 2013-01-30
2
229 Views
Last Modified: 2013-02-17
I wish to do selective copy paste from one file to another:

Copy Column A:F from Sheet 1

Paste on Sheet 2, so that

Sheet 1                          Sheet 2
Values of Column A = Values of Column A
Values of Column B = Values of Column C
Values of Column C = Values of Column E ... and so on.

unable to use visible cells only copy paste option. plz. help.

regards.
0
Comment
Question by:peeyushmiglani
2 Comments
 
LVL 45

Expert Comment

by:aikimark
ID: 38838244
Your choices seem to be:
* do a regular copy/paste and insert a new column B in sheet 2.

* do two copy/paste operations

* implement a direct value copy with two VBA statements
0
 
LVL 14

Accepted Solution

by:
Faustulus earned 500 total points
ID: 38846123
Please try this code:-
Option Explicit

Sub TransferData()

    Dim WsT As Worksheet            ' Target sheet
    Dim WsS As Worksheet            ' Source sheet
    Dim C As Long                   ' Source column
    
    Set WsS = Sheets("Sheet1")
    Set WsT = Sheets("Sheet2")
    Application.ScreenUpdating = False
    
    For C = 6 To 2 Step -1         ' insert columns
        WsS.Columns(C).Insert
    Next C
    
    With WsS
        Range(.Columns(1), .Columns(11)).Copy Destination:=WsT.Cells(1, 1)
    End With
    
    For C = 2 To 6                 ' delete blank columns
        WsS.Columns(C).Delete
    Next C
    Application.ScreenUpdating = True
End Sub

Open in new window

I think it should accomplish what you wish to do.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My experience with Windows 10 over a one year period and suggestions for smooth operation
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question