need help for copying among workbooks

  • Thread starter Thread starter snow
  • Start date Start date
S

snow

Hello everyone, these are the facts:
I need to copy data from some columns of sheet1 of workbook1 to sheet2
of workbook5
then do the same thing (sequentially) for workbook 2,3,4 , just
copying their A-J columns to sheet2 of workbook5...and the columns
from WB2,3,4 need to be pasted in the first empty column of sheet2 of
WB5

I also need to be able to select (browsing in my hard disk) the file
representing workbook5.

I think a way is to define a macro for WB 1,2,3,4 that allows me to
select the column I want to copy and paste and put them in the first
empty column of sheet2 of WB5...

really hope sone can help me...:((
 
Sub CopyBooks1234()
Dim sh1 as Worksheet, sh2 as Worksheet
Dim sh3 as Worksheet, sh4 as Worksheet
Dim sh5 as Worksheet, fName as Variant
dim bk5 as Workbook, rng as Range
fName = Application.GetOpenfileName()
if fName = False then exit sub
set bk5 = workbooks.Open(fName)

set sh1 = workbooks("Workbooks1.xls").Worksheets("Sheet1")
set sh2 = workbooks("Workbooks2.xls").Worksheets("Sheet1")
set sh3 = workbooks("Workbooks3.xls").Worksheets("Sheet1")
set sh4 = workbooks("Workbooks4.xls").Worksheets('Sheet1")
set sh5 = bk5.Worksheets(2)
set rng = sh5.cells(1,"IV").End(xltoLeft)(1,2)
sh1.columns(1).Resize(10).Copy destination:=rng
sh2.columns(1).Resize(10).Copy destination:=rng.Offset(0,10)
sh3.columns(1).Resize(10).Copy destination:=rng.Offset(0,20)
sh4.columns(1).Resize(10).Copy destination:=rng.Offset(0,30)
end Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top