Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006

    Unanswered: Modify function to receive values as parameters

    Hi: Can any one please tell me how to write a function which will copy both excel file into the third one but dont know how to i modify the function so that it will receive the two excel files into it as parameters and then process into the third one?

    Sub AppendRows()
    Dim arr As Variant
    Dim x As Integer
    Dim wsdest As Worksheet
    Dim wssrc As Worksheet
    Dim rngdest As Range

    arr = Array("c:\test\a.xls", "c:\test\b.xls", "c:\test\c.xls")
    Set wsdest = ThisWorkbook.Sheets("Sheet1")

    For x = LBound(arr) To UBound(arr)
    Set wssrc = Workbooks.Open(arr(x)).Sheets("Sheet1")
    wssrc.Rows(1).Copy Destination:=wsdest.Rows(1)
    Set rngdest = wsdest.Range("A65536").End(xlUp).Offset(1, 0)
    wssrc.Cells("A1").CurrentRegion.Offset(1, 0).Copy Destination:=rngdest
    wssrc.Parent.Close SaveChanges:=False
    Next x
    End Sub

  2. #2
    Join Date
    Jan 2007
    Provided Answers: 10
    I think this is your starting point (declaring that it recieves 3 parameters)

    Function AppendRows(Xls1 As String, Xls2 As String, Xls3 As String)
    Home | Blog

Posting Permissions

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