Consulting

Results 1 to 3 of 3

Thread: Sleeper: Open closed excel file

  1. #1

    Sleeper: Open closed excel file

    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

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    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

  3. #3
    thank you for your quick responce, i hope to try this out on monday at work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •