ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   accessing worksheets from 2 excel files (https://www.excelbanter.com/excel-programming/360022-accessing-worksheets-2-excel-files.html)

ashishprem[_17_]

accessing worksheets from 2 excel files
 

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

--
ashishpre
-----------------------------------------------------------------------
ashishprem's Profile: http://www.excelforum.com/member.php...fo&userid=3148
View this thread: http://www.excelforum.com/showthread.php?threadid=53714


pianoman[_6_]

accessing worksheets from 2 excel files
 

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...

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



--
pianoman
------------------------------------------------------------------------
pianoman's Profile: http://www.excelforum.com/member.php...o&userid=33712
View this thread: http://www.excelforum.com/showthread...hreadid=537141


ashishprem[_18_]

accessing worksheets from 2 excel files
 

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


Tom Ogilvy

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




All times are GMT +1. The time now is 02:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com