+ Reply to Thread
Results 1 to 4 of 4

accessing worksheets from 2 excel files

  1. #1
    Registered User
    Join Date
    02-13-2006
    Posts
    46

    accessing worksheets from 2 excel files

    Hi,
    I want to compare 2 worksheets present in 2 different excel files. Is there any way to do it?
    Regards,
    Ashish

  2. #2
    Registered User
    Join Date
    04-21-2006
    Posts
    61
    What are you trying to compare? Would copying the two sheets into one 'Comparison' workbook be appropriate? The code is simpler if you're only swtiching sheets instead of books...

    Quote Originally Posted by ashishprem
    Hi,
    I want to compare 2 worksheets present in 2 different excel files. Is there any way to do it?
    Regards,
    Ashish

  3. #3
    Registered User
    Join Date
    02-13-2006
    Posts
    46
    The copying will solve the problem definitely. Actually i am getting two excel sheets daily which are needs to be compared. I am copying both the sheets in one excel file and pasting the macro in the same excel file and then i am running the macro to get the compared result. Its pretty hectic.So is there any way by which i can just give the path name for 2 files and get the compared result.

  4. #4
    Tom Ogilvy
    Guest

    Re: accessing worksheets from 2 excel files

    If you write the macro to operate that way, it can open the two workbooks,
    create the combined workbook and then do the comparison.

    Your description is so vague, that it it is hard to say much beyond that.

    What don't you know how to do.

    You don't know how to open a workbook with code?
    Dim fName as Variant
    Dim fname1 as Variant
    Dim bk as Workbook, bk1 as Workbook
    Dim bk2 as Workbook, rng2 as Range
    fname = Application.GetOpenfileName()
    if fname <> False then
    set bk = workbooks.Open(fName)
    end if
    fName1 = Application.GetOpenfileName()
    if fName1 <> False then
    set bk1 = Workbooks.Open(fName1)
    end if
    if bk1 is nothing or bk2 is nothing then
    msgbox "Faild to designate two workbooks"
    exit sub
    end if
    set bk2 = Worbooks.add
    bk.worksheets(1).Range("A1").CurrentRegion.copy _
    bk2.Worksheets(1).Range("A1")
    set rng2 = bk2.worksheets(1).Cells(rows.count,1).end(xlup)(2)
    bk1.Worksheets(1).Range("A1").CurrentRegion.copy _
    rng2
    bk.close Savechanges:=False
    bk1.Close Savechanges:=False

    conceptually, this should create a third workbook with data from each of the
    first two workbooks.

    --
    Regards,
    Tom Ogilvy





    "ashishprem" wrote:

    >
    > The copying will solve the problem definitely. Actually i am getting two
    > excel sheets daily which are needs to be compared. I am copying both the
    > sheets in one excel file and pasting the macro in the same excel file
    > and then i am running the macro to get the compared result. Its pretty
    > hectic.So is there any way by which i can just give the path name for 2
    > files and get the compared result.
    >
    >
    > --
    > ashishprem
    > ------------------------------------------------------------------------
    > ashishprem's Profile: http://www.excelforum.com/member.php...o&userid=31485
    > View this thread: http://www.excelforum.com/showthread...hreadid=537141
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1