PDA

View Full Version : Copying data from another Workbook row wise



Eva_Johansso
12-15-2013, 11:43 AM
Hi guys!

Wanted to copy data values from one workbook to another in a worksheet column wise I came up with the following code and it is working


Sub copy()
Dim wbMain As Workbook
Dim wbData As Workbook

Set wbMain = ActiveWorkbook
Set wbData = Workbooks.Open("C:\Users\Naveed\Desktop\Excel Project\Test\Data.xlsx")

wbData.Sheets(1).Range("A1:A5").copy
wbMain.Sheets(1).Range("A1:A5").PasteSpecial
End Sub


But now i want to copy data row wise
for instance values in the data workbook is stored on a range B21, C21, D21, E21..... up to AF21. how to copy that range to the Main workbook.

To answer your question... yes I have two different workbooks, Main and Data. Main has the button on its sheet(1) and i want to copy data from sheet(1) on workbook Data

my attempt


'source copy range
wbData.Sheets(1).Range("B21:AF21").Copy

'destination paste range
wbMain.Sheets(1).Range("B1").PasteSpecial xlPasteValues

But every time I run the code it shows the dotted rectangle around the range how to remove it?

Any help would be appreciated
BR

Bob Phillips
12-15-2013, 04:48 PM
Did the copy work, and you just want to get id of those dots? If so


Application.CutCopyMode = False