copying cells with data only into different workbook

BrutalLogiC

Active Member
Joined
Feb 26, 2006
Messages
267
Office Version
  1. 2016
Platform
  1. Windows
hey would it be possible to copy data from one work book to another but ignore any blank cells on the original workbook?

e.g. I have this one workbook where only columns A, C, E, G etc have data in them. I want to copy that data into the 2nd workbook but don't want to copy the blank cells/columns in-between (e.g. columns B, D etc.)
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try something like this...
Code:
    [COLOR=darkblue]Dim[/COLOR] wb2 [COLOR=darkblue]As[/COLOR] Workbook [COLOR=green]'Source workbook[/COLOR]
    
    [COLOR=darkblue]Set[/COLOR] wb2 = Application.Workbooks("Book2.xlsx")
    
    [COLOR=green]'Copy[/COLOR]
    Intersect(wb2.Sheets(1).UsedRange, wb2.Sheets(1).Range("A:A, C:C, E:E, G:G")).Copy
    [COLOR=green]'Paste[/COLOR]
    ThisWorkbook.Sheets(1).Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteAll
    
    Application.CutCopyMode = [COLOR=darkblue]False[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,868
Messages
6,127,413
Members
449,382
Latest member
DonnaRisso

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