View Single Post
  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default How copy cell workbook to workbook?

How would you ever know which workbook is workbooks(1) and which is
workbooks(2)?

I think I'd be much more specific (well, if it's possible)

Sub Copy_Cell_from_2ndbook_to_1st_book()
Workbooks("book1.xls").Worksheets(1).Cells(5, 2).Value = _
Workbooks("book2.xls").Worksheets(1).Cells(2, 3).Value
MsgBox "Done"
End Sub

or even...

Sub Copy_Cell_from_2ndbook_to_1st_book()
Workbooks("book1.xls").Worksheets("sheet1").Cells( 5, 2).Value = _
Workbooks("book2.xls").Worksheets("sheet1").Cells( 2, 3).Value
MsgBox "Done"
End Sub

I'm betting that your code worked perfectly--it just didn't do it to the
workbooks you wanted.

adding:

msgbox workbooks(1).worksheets(1).range("B5").address(ext ernal:=true) _
& vblf & workbooks(2).worksheets(1).range("C2").address(ext ernal:=true)

might give you a clue on what got changed.

wrote:

Can someone tell me why this isn't copying cell 2,3 in 2nd workbook to
cell 5,2 in 1st workbook? It prints the msgbox properly and runs w/o
runtime errors.

Sub Copy_Cell_from_2ndbook_to_1st_book()
Workbooks(1).Worksheets(1).Cells(5, 2).Value =
Workbooks(2).Worksheets(1).Cells(2, 3).Value
MsgBox "Done"
End Sub

Thanks!


--

Dave Peterson