How to refer to an other worksheet (or book)

N

noyau

The following logic exist to form an archive of the changing values of A1
and A2 (.Cells(xlr, 8) = .Range("A1")). What if A1 value of an other excel
sheet (or book) (other then "sheet1") is referenced?

Sub ArchiveA2()
Dim xlr As Long
With Sheets("Sheet1")
.Range("G1") = "Value"
xlr = .Cells(Rows.Count, "G").End(xlUp).Row + 1
.Cells(xlr, 7) = Format(Date, "dd/mm/yyyy")
.Cells(xlr, 8) = .Range("A1")
.Cells(xlr, 9) = .Range("A2")
End With
End Sub
 
N

noyau

Thank you Alok, that will solve my problems. I wonder how I should move in
order to reference to an other Excel Book (for example a "Book1" in the
desktop) instead of just another sheet. I was unable to get a solution from
my trials and from help menu.
 

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

Top