How to refer to an other worksheet (or book)
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 |
How to refer to an other worksheet (or book)
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. "Alok" wrote: Hi noyau, The following line will change .Cells(xlr, 8) = Worksheets("Sheet2").Range("A1") Alok "noyau" wrote: 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 |
All times are GMT +1. The time now is 04:14 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com