copying entire column

  • Thread starter Thread starter Charlie
  • Start date Start date
C

Charlie

I have a workbook open with 3 columns of data & then open a second.

Set newApp = New Excel.Application
newApp.Workbooks.Open xlsFile

I then get some header info from the 2nd workbbok
Set row = human.Worksheets(1).Rows(1)
For i = 2 To maxHdr + 1
hdr(i - 1) = UCase(row.Cells(i).Text)
Next i

Next I try to copy the 1st column from the 2nd workbook to the 1st
column of the 1st workbook - overlaying the existing data in the 1st
column
Dim inCol, outCol As Range
Set inCol = human.Worksheet(1).Columns(1)
Set outCol = Application.ActiveWorkbook.Worksheets(1).Columns(1)
inCol.Copy Destination:=Application.ActiveWorkbook.Worksheets(1).Columns(1)

I've tried several permeations of the copy statement but it never gets
displayed.
Any help appreciated. thanks...charlie
 
Charlie, try

Sub CopyColumns()
Dim RngSrc As Range
Dim RngDest As Range
Set RngSrc = Workbooks("Book2").Sheets
("Sheet1").Columns(1)
Set RngDest = Workbooks("Book3").Sheets
("Sheet1").Columns(1)
RngSrc.Copy RngDest
End Sub

Regards,

John Mansfield
The Planning Deskbook
http://www.pdbook.com
 
I tried that but it doesn't seem to work.
In you example are "Book2" and "Book3" the actual text name of the
path & file name of the workbooks, and "Sheet1" the name of the sheet
in the workbook?
That is what I put in there.
 

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