PDA

View Full Version : Sleeper: Open closed excel file



alexanderd
07-03-2005, 04:31 AM
i am trying to open an excel file " A.xls" which is password protected "password=AbC" from from another file "B".
I would like to read the last cell in colum "A" of file "A" and add 1 to it and paste into file "B".
row 2:2 of file "B" has to be pasted to end of file "A"

any help would be appreciated:banghead:

Jacob Hilderbrand
07-03-2005, 10:33 AM
Try something like this.


Option Explicit

Sub Macro1()
Dim Wkb As Workbook
Dim Path As String
Dim FName As String
Dim Pass As String
Dim Str As String
Dim LastRow As Long
Path = ThisWorkbook.Path
FName = "A.xls"
Pass = "ABC"
Set Wkb = Workbooks.Open(Filename:=Path & "\" & FName, Password:=Pass)
LastRow = Wkb.Sheets(1).Range("A65536").End(xlUp).Row
Wkb.Sheets(1).Range("A" & LastRow).Value = Wkb.Sheets(1).Range("A" & LastRow).Value + 1
Wkb.Sheets(1).Range("A" & lastrow).Copy Destination:= ??Paste Location Here??
ThisWorkbook.Sheets(i).Range("A2").EntireRow.Copy Destination:=Wkb.Sheets(1).Range("A" & LastRow + 1)
Wkb.Close SaveChanges:=True
End Sub

alexanderd
07-03-2005, 11:58 AM
thank you for your quick responce, i hope to try this out on monday at work