View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
gjameson via OfficeKB.com gjameson via OfficeKB.com is offline
external usenet poster
 
Posts: 14
Default Copy cells from another workbook

Joel that worked great! Thank you so much.

Gerald

joel wrote:
You didn't specify which sheets in the workbook you are using so
chose the first tab in each workbook.

Sub AddData()

With ThisWorkbook.Sheets(1)
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
Newrow = LastRow + 1
Set DestLocation = .Range("A" & Newrow)
End With

fileToOpen = Application _
.GetOpenFilename("Excel Files (*.xls), *.xls")
If fileToOpen = False Then
MsgBox ("cannot Open file - Exiting Macro")
Exit Sub
End If

Set bk = Workbooks.Open(Filename:=fileToOpen)
Set sht = bk.Sheets(1)

With sht
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
Set Copyrange = .Range("A9:I" & LastRow)
Copyrange.Copy _
Destination:=DestLocation
End With

bk.Close savechanges:=False

End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/201003/1