ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy empty cells from one workbook to another - Code (https://www.excelbanter.com/excel-programming/340916-copy-empty-cells-one-workbook-another-code.html)

David Choen

Copy empty cells from one workbook to another - Code
 
Hello,

Sorry for posting 2 times. Date & time in my computer were not correctly
set.

In addition to what I've written before, here is the code I wrote:

Sub Dataacquire()
Workbooks.Open "data.xls"
Worksheets("sheet1").Range("b1:d19").Copy _
ThisWorkbook.Worksheets("sheet1").Range("b1:d19")
ActiveWorkbook.Close SaveChanges:=False
End Sub

My problem that empty cells are not copied as empty and
because of this I get an error messages in other worksheets (like #VALUE).

How Can I solve this problem ?

Thank you
David Cohen






Vacation's Over

Copy empty cells from one workbook to another - Code
 
3 suggestions
1) copy Values so that any formulas or other file specifics are left behind
2) since you know the file name close it by name, avoids issues if you add
more code later
3) clear the clipboard after copy

Sub Dataacquire()
Workbooks.Open "data.xls"
Worksheets("sheet1").Range("b1:d19").Value.Copy _
ThisWorkbook.Worksheets("sheet1").Range("b1:d19")
Application.cutcopymode = False
Workbooks("data.xls").Close SaveChanges:=False
End Sub

"David Choen" wrote:

Hello,

Sorry for posting 2 times. Date & time in my computer were not correctly
set.

In addition to what I've written before, here is the code I wrote:

Sub Dataacquire()
Workbooks.Open "data.xls"
Worksheets("sheet1").Range("b1:d19").Copy _
ThisWorkbook.Worksheets("sheet1").Range("b1:d19")
ActiveWorkbook.Close SaveChanges:=False
End Sub

My problem that empty cells are not copied as empty and
because of this I get an error messages in other worksheets (like #VALUE).

How Can I solve this problem ?

Thank you
David Cohen








All times are GMT +1. The time now is 08:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com