Hi,
I want to compare 2 worksheets present in 2 different excel files. Is there any way to do it?
Regards,
Ashish
Hi,
I want to compare 2 worksheets present in 2 different excel files. Is there any way to do it?
Regards,
Ashish
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...
Originally Posted by ashishprem
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.
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
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks