Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Macro help required !

Hi All,

I have excel file named as A.xls & B.xls

I get A.xls in morning and B.xls in Evening.( day 1 )

Once i get B.xls I need to compare this workbook with A.xls

ie., Col A has some codes in all workbooks that will repeated some
times.
So, If i know which one is repeated i will prioritize the work.

Here is an example,

A.xls
Col A
ABC45
IND45
AUD45
CZK47

B.xls
Col A
ABC47
IND45
AUD48
AUD46
CZK47
IN45

Compare B.xls with A.xls - there are some repeated codes.
i.e, IND45 & CZK47
i need the word "repeated" if it matches with A.xls in col B for B.xls

What I need ?
I will open B.xls and if i run the macro open dialog will come then I
will select
the A.xls and it need ask which sheet u need match, and then I will
select the sheet.
Then it will match.

File are not constant ...
Tomorrow I will receive C.xls then I need to compare with B.xls
if i received D.xls then I will compare with C.xls...... goes
on ,,,,,,

Thanks a lot in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Macro help required !

Here's a start. You'll need to provide more information for someone to
assist further, I suspect.

Option Explicit
Sub Test()
Dim aWB As Workbook
Dim bWB As Workbook
Dim aWS As Worksheet
Dim bWS As Worksheet

Set aWB = OpenWorkbook("First")
Set bWB = OpenWorkbook("Second")

'Need code to select the worksheets
' I know this isn't what you're asking for, but it's a start.
' Maybe someone else can assist
' I'd probably set a codename for the worksheet
' and reference that

Set aWS = aWB.Worksheets(1)
Set bWS = bWB.Worksheets(1)

'I'm not sure which columns you want to match
' So you'll need to provide more information
' on that

End Sub

Function OpenWorkbook(myTitle As String) As Workbook
Dim sFile As String
Dim ShortName As String


With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Title = "Find and open the" & myTitle & " workbook."
If .Show = False Then
MsgBox ("You cancelled opening the " & myTitle & " file. Execution
ending.")
End
End If
sFile = .SelectedItems
End With

ShortName = Right(sFile, Len(sFile) - InStrRev(sFile, "\"))

Set OpenWorkbook = Nothing
On Error Resume Next
Set OpenWorkbook = Workbooks(ShortName)

If OpenWorkbook Is Nothing Then
Set OpenWorkbook = Workbooks.Open(Filename:=sFile)
End If
End Function

'UNTESTED.

--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



" wrote:

Hi All,

I have excel file named as A.xls & B.xls

I get A.xls in morning and B.xls in Evening.( day 1 )

Once i get B.xls I need to compare this workbook with A.xls

ie., Col A has some codes in all workbooks that will repeated some
times.
So, If i know which one is repeated i will prioritize the work.

Here is an example,

A.xls
Col A
ABC45
IND45
AUD45
CZK47

B.xls
Col A
ABC47
IND45
AUD48
AUD46
CZK47
IN45

Compare B.xls with A.xls - there are some repeated codes.
i.e, IND45 & CZK47
i need the word "repeated" if it matches with A.xls in col B for B.xls

What I need ?
I will open B.xls and if i run the macro open dialog will come then I
will select
the A.xls and it need ask which sheet u need match, and then I will
select the sheet.
Then it will match.

File are not constant ...
Tomorrow I will receive C.xls then I need to compare with B.xls
if i received D.xls then I will compare with C.xls...... goes
on ,,,,,,

Thanks a lot in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Macro help required !

Hi Barb,

Everyday I receive two excel files only col A has some codes - those
are in sheet2 most of the time. It may come in sheet1 or sheet3.

col A - a.xls Col A - b.xls
123 456
456 abc
789 jhi
abc
efg

I have to run a macro for b.xls here in col A there are 3 codes which
need to match with a.xls Col A.
We can easily make out only 456 & abc are matching. next 456 i need a
word "repeated" as it is
matching with a.xls Col A......

This is what i want. ...



On Dec 15, 2:16*am, Barb Reinhardt
wrote:
Here's a start. * You'll need to provide more information for someone to
assist further, I suspect.

Option Explicit
Sub Test()
Dim aWB As Workbook
Dim bWB As Workbook
Dim aWS As Worksheet
Dim bWS As Worksheet

Set aWB = OpenWorkbook("First")
Set bWB = OpenWorkbook("Second")

'Need code to select the worksheets
' *I know this isn't what you're asking for, but it's a start.
' *Maybe someone else can assist
' *I'd probably set a codename for the worksheet
' *and reference that

Set aWS = aWB.Worksheets(1)
Set bWS = bWB.Worksheets(1)

'I'm not sure which columns you want to match
' *So you'll need to provide more information
' *on that

End Sub

Function OpenWorkbook(myTitle As String) As Workbook
Dim sFile As String
Dim ShortName As String

With Application.FileDialog(msoFileDialogFilePicker)
* * .AllowMultiSelect = False
* * .Title = "Find and open the" & myTitle & " workbook."
* * If .Show = False Then
* * * * MsgBox ("You cancelled opening the " & myTitle & " file. *Execution
ending.")
* * * * End
* * End If
* * sFile = .SelectedItems
End With

ShortName = Right(sFile, Len(sFile) - InStrRev(sFile, "\"))

Set OpenWorkbook = Nothing
On Error Resume Next
Set OpenWorkbook = Workbooks(ShortName)

If OpenWorkbook Is Nothing Then
* * Set OpenWorkbook = Workbooks.Open(Filename:=sFile)
End If
End Function

'UNTESTED.

--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



" wrote:
Hi All,


I have excel file named as A.xls & B.xls


I get A.xls in morning and B.xls in Evening.( day 1 )


Once i get B.xls I need to compare this workbook with A.xls


ie., Col A has some codes in all workbooks that will repeated some
times.
So, If i know which one is repeated i will prioritize the work.


Here is an example,


A.xls
Col A
ABC45
IND45
AUD45
CZK47


B.xls
Col A
ABC47
IND45
AUD48
AUD46
CZK47
IN45


Compare B.xls with A.xls - *there are some repeated codes.
i.e, IND45 & CZK47
i need the word "repeated" if it matches with A.xls in col B for B.xls


What I need ?
I will open B.xls and if i run the macro open dialog will come then I
will select
the A.xls and it need ask which sheet u need match, and then I will
select the sheet.
Then it will match.


File are not constant ...
Tomorrow I will receive C.xls then I need to compare with B.xls
if i received D.xls then I will compare with C.xls...... goes
on ,,,,,,


Thanks a lot in advance.- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Macro help required !

Hi Barb,

I have tiny macro to do that job, but that is not complete.
Please assist me to complete this job.

please two workbook named as a.xls & b.xls

Col A put some letter or numbers in both ( a.xls & b.xls - Sheet 2 )
which starts from A2 and end at A10 ( this is an example )

in b.xls put this macro and run it from b.xls .....

Sub matcher()
Dim str As String
Range("B2").Select
a = ActiveWorkbook.Name
Application.Dialogs(xlDialogOpen).Show (str)
b = ActiveWorkbook.Name
Workbooks(a).Activate
Do Until ActiveCell.Offset(0, -1).Value = ""
ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]=[a.xls]Sheet2!R2C1:R10C1,""repeated"","""")"
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Offset(1, 0).Select
Range("B2:B10").Select
Selection.Copy
Range("b2").Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Range("A1").Select
End Sub

this is running fine only when i know the file name and sheet name ...
this file name and sheet name changes from day to day.
As I inserted file name and sheet name in formula.

Hope u will reply to me..

Thanks





On Dec 15, 2:16*am, Barb Reinhardt
wrote:
Here's a start. * You'll need to provide more information for someone to
assist further, I suspect.

Option Explicit
Sub Test()
Dim aWB As Workbook
Dim bWB As Workbook
Dim aWS As Worksheet
Dim bWS As Worksheet

Set aWB = OpenWorkbook("First")
Set bWB = OpenWorkbook("Second")

'Need code to select the worksheets
' *I know this isn't what you're asking for, but it's a start.
' *Maybe someone else can assist
' *I'd probably set a codename for the worksheet
' *and reference that

Set aWS = aWB.Worksheets(1)
Set bWS = bWB.Worksheets(1)

'I'm not sure which columns you want to match
' *So you'll need to provide more information
' *on that

End Sub

Function OpenWorkbook(myTitle As String) As Workbook
Dim sFile As String
Dim ShortName As String

With Application.FileDialog(msoFileDialogFilePicker)
* * .AllowMultiSelect = False
* * .Title = "Find and open the" & myTitle & " workbook."
* * If .Show = False Then
* * * * MsgBox ("You cancelled opening the " & myTitle & " file. *Execution
ending.")
* * * * End
* * End If
* * sFile = .SelectedItems
End With

ShortName = Right(sFile, Len(sFile) - InStrRev(sFile, "\"))

Set OpenWorkbook = Nothing
On Error Resume Next
Set OpenWorkbook = Workbooks(ShortName)

If OpenWorkbook Is Nothing Then
* * Set OpenWorkbook = Workbooks.Open(Filename:=sFile)
End If
End Function

'UNTESTED.

--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



" wrote:
Hi All,


I have excel file named as A.xls & B.xls


I get A.xls in morning and B.xls in Evening.( day 1 )


Once i get B.xls I need to compare this workbook with A.xls


ie., Col A has some codes in all workbooks that will repeated some
times.
So, If i know which one is repeated i will prioritize the work.


Here is an example,


A.xls
Col A
ABC45
IND45
AUD45
CZK47


B.xls
Col A
ABC47
IND45
AUD48
AUD46
CZK47
IN45


Compare B.xls with A.xls - *there are some repeated codes.
i.e, IND45 & CZK47
i need the word "repeated" if it matches with A.xls in col B for B.xls


What I need ?
I will open B.xls and if i run the macro open dialog will come then I
will select
the A.xls and it need ask which sheet u need match, and then I will
select the sheet.
Then it will match.


File are not constant ...
Tomorrow I will receive C.xls then I need to compare with B.xls
if i received D.xls then I will compare with C.xls...... goes
on ,,,,,,


Thanks a lot in advance.- Hide quoted text -


- Show quoted text -


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro required please Dr Hackenbush Excel Discussion (Misc queries) 4 February 10th 10 09:29 AM
Macro required PCOR Excel Worksheet Functions 3 December 11th 05 07:36 PM
Pilgrim needs help: Effecting keystroks required by a macro nested within a macro. [email protected] Excel Programming 1 May 14th 05 03:46 AM
MACRO HELP REQUIRED PLEASE! Fletch[_3_] Excel Programming 4 March 31st 05 01:46 PM
Macro help required! Don Niall Excel Programming 7 June 24th 04 07:12 PM


All times are GMT +1. The time now is 09:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"