Copy to Another

billandrew

Well-known Member
Joined
Mar 9, 2014
Messages
743
Looking to copy 6 columns which are not adjacent to each other, if cell value = a specific criteria to another Workbook starting in Column K.
The column row height could change when received.

The order on the copied "Master" sheet is
- Column B
- Column C
- Column I
- Column J
- Column E
- Column F


Hope this provides the necessary info.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
What is the specific criteria? In which column is the criteria? What is the destination sheet name? What is the destination workbook name including the extension (xls, xlsx, xlsm)?
 
Upvote 0
The data is in the colums stated in Post 1. The destination workbook is "Daily Report". The file extension of the destination workbook is .xlsx
The file extension of the data to be copied is csv.

Thank you
 
Upvote 0
Can you post a screen shot of what your data looks like? Section B at this link has instructions on how to post a screen shot: https://www.mrexcel.com/forum/board-announcements/127080-guidelines-forum-use.html Alternately, you could upload a copy of your file to a free site such as www.box.com. or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Include a detailed explanation of what you would like to do referring to specific cells and worksheets. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0
Date

<tbody>
</tbody>
Product

<tbody>
</tbody>
Region CustomerQty RevCogIDProfitCode
40084

<tbody>
</tbody>
A292CentralMJewelry4008517465410013953R
39897

<tbody>
</tbody>
B722

<tbody>
</tbody>
WestAGlass9402314411703100211485S
40072

<tbody>
</tbody>
E438

<tbody>
</tbody>
CentralRSafety Company1905520295810032562D
40098

<tbody>
</tbody>
E438

<tbody>
</tbody>
EastBPlastic1303933202410041909W
39941

<tbody>
</tbody>
C409

<tbody>
</tbody>
WestMJewelry4401130459361005
5368P
40048

<tbody>
</tbody>
E438

<tbody>
</tbody>
NorthMJewelry57017584887510068709K
40056

<tbody>
</tbody>
D625

<tbody>
</tbody>
EastBPlastic38010196552110074675R
40039

<tbody>
</tbody>
D625

<tbody>
</tbody>
NorthAce Contruction690183221002610088296S
40133

<tbody>
</tbody>
E438

<tbody>
</tbody>
CentralMJewelry58016850903110097819D
40101

<tbody>
</tbody>
A292

<tbody>
</tbody>
WestMarks Roofing55011228627610104952S
39964

<tbody>
</tbody>
C409

<tbody>
</tbody>
EastGood Traders9102314312276101110867R

<tbody>
</tbody>


Above is a small sample of the data.

if column C = North or Central copy Column B ,C, I, J, E & F to Workbook 2 Sheet1.
 
Upvote 0
Make sure that both workbooks are open and that the "Master" sheet in the source workbook is the active sheet. Place this macro in a regular module in the source workbook and run it from there.
Code:
Sub CopyCols()
    Application.ScreenUpdating = False
    Dim bottomA As Long
    bottomA = Range("A" & Rows.Count).End(xlUp).Row
    Range("A1:J" & bottomA).AutoFilter Field:=3, Criteria1:="=Central", Operator:=xlOr, Criteria2:="=North"
    Intersect(Rows("2:" & bottomA), Range("B:B,C:C,I:I,J:J,E:E,F:F")).Copy Workbooks("Daily Report.xlsx").Sheets("Sheet1").Cells(Rows.Count, "K").End(xlUp).Offset(1, 0)
    If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Wow

Mumps, I am unable to try this at the moment, however I gave you so little and very disorganized description of what I needed and you continued with the above. I can't say enough Thanks....

and I'm sure it will work.
 
Upvote 0
Glad to help. :) Please let me know if it doesn't work out.
 
Upvote 0
The Filter and copy work perfect, however the order in which I need the columns to be pasted in the Daily Report are incorrect. If possible I need the Order to be

Column B, Column C, Column I Column J, Column E, Column F. Currently is placing the copied Columns in their order on the Start Worksheet.
 
Upvote 0
Working on another method (see below) however this does the same as the code provided and is not as fast or efficient.

I found a workaround, not too sure I like it though. I use the first 4 columns ( B, C, I & J) in one module, run the code, then in a second module use the remaining Columns I want adjacent to Column J which is Columns D & E. This works however I think there is a better way.

Thanks for any help on this...

Code:
[Sub CopyColData2()
        Dim Finalrow As Long, lastRow As Long, i As Long
        Dim Rng2Copy As Range
        Dim Ws As Worksheet, Ws2 As Worksheet
        Set Ws = Workbooks("Master.csv").Worksheets("Sheet1")
        Set Ws2 = Workbooks("Daily Report.xlsx").Worksheets("Sheet1")
        Application.ScreenUpdating = True
        Ws.Activate
        With Ws
        lastRow = .Cells(.Rows.Count, 3).End(xlUp).Row
        For i = 2 To lastRow
        If Trim(.Cells(i, "C").Value) = "Central" Or Trim(.Cells(i, "C").Value) = "North" Then
        Set Rng2Copy = Application.Union(.Range("B" & i), .Range("C" & i), .Range("I" & i), .Range("J" & i), .Range("E" & i), .Range("F" & i))
            Rng2Copy.Copy
            
            Finalrow = Ws2.Cells(.Rows.Count, "K").End(xlUp).Offset(1, 0).Row
            Ws2.Range("K" & Finalrow).PasteSpecial xlPasteAll
            End If
            Next i
            End With      
 Application.ScreenUpdating = False
        End Sub/CODE]
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,670
Members
449,248
Latest member
wayneho98

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top