PC Review


Reply
Thread Tools Rate Thread

Compare the contents of a cell with a column in another workbook

 
 
DDawson
Guest
Posts: n/a
 
      19th Feb 2008
I want to compare the contents of a cells A2:A3000 with a column (or defined
name) in another workbook. And, if a match is found, I want to enter a
comment in a cell on the same row, column G of the first workbook?
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      19th Feb 2008
This is untested:

Sub IsItThere()
For Each c In ActiveSheet.Range("A2:A3000")
If Not c Is Nothing Then
Set findC = Worksheets(2).Cells _
.Find(c.Value, LookIn:=xlValues)
If Not findC Is Nothing Then
ActiveSheet.Range("G" & c.Row).AddComment _
.Visible = False _
.Text = "Found it"
End If
End If
Next
End Sub

"DDawson" wrote:

> I want to compare the contents of a cells A2:A3000 with a column (or defined
> name) in another workbook. And, if a match is found, I want to enter a
> comment in a cell on the same row, column G of the first workbook?

 
Reply With Quote
 
eliano
Guest
Posts: n/a
 
      20th Feb 2008
Hi JLG.

Tested, but my xl2003 require a With....End With to work properly.
However many thanks.

Sub IsItThere() 'by JLGWitz
Dim c As Range
Dim findC As Variant

For Each c In ActiveSheet.Range("A2:A3000")
If Not c Is Nothing Then
Set findC = Worksheets(2).Cells _
.Find(c.Value, LookIn:=xlValues)
If Not findC Is Nothing Then
'---
With ActiveSheet.Range("G" & c.Row).AddComment '<-----
.Visible = False
.Text "Found it" '<-----
End With
'---
End If
End If
Next
End Sub

Regards
Eliano




On 19 Feb, 19:55, JLGWhiz <JLGW...@discussions.microsoft.com> wrote:
> This is untested:
>
> Sub IsItThere()
> * For Each c In ActiveSheet.Range("A2:A3000")
> * * If Not c Is Nothing Then
> * * * Set findC = Worksheets(2).Cells _
> * * * * * * * * * .Find(c.Value, LookIn:=xlValues)
> * * * * If Not findC Is Nothing Then
> * * * * * ActiveSheet.Range("G" & c.Row).AddComment _
> * * * * * * *.Visible = False _
> * * * * * * *.Text = "Found it"
> * * * * End If
> * * End If
> * Next
> End Sub
>
>
>
> "DDawson" wrote:
> > I want to compare the contents of a cells A2:A3000 with a column (or defined
> > name) in another workbook. And, if a match is found, I want to enter a
> > comment in a cell on the same row, column G of the first workbook?- Nascondi testo tra virgolette -

>
> - Mostra testo tra virgolette -


 
Reply With Quote
 
DDawson
Guest
Posts: n/a
 
      20th Feb 2008
Thank you JLG and Eliano,

Here is the amended macro I used to enter a "comment" (it enters a value to
the cell rather than in a comment box adjacent) as text in each cell of my
Report where each cell in column A contains a value that appeared in my
SourceDoc(Sheet1). I Hope this makes sense.

Ideally it checks column B of the SourceDoc against column A of the Report
and if a matching entry is found, it enters the date in Column A of the
report, on the same row as the check value.

Sub CheckData()
Dim c As Range
Dim findC As Variant

With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

Windows("Report.xls").Activate '<-- My report
For Each c In ActiveSheet.Range("A2:A90")
If Not c Is Nothing Then
Windows("SourceDoc.xls").Activate '<-- My document to be checked
Set findC = Worksheets("Sheet1").Cells _
.Find(c.Value, LookIn:=xlValues)

If Not findC Is Nothing Then

Windows("Report.xls").Activate
ActiveSheet.Range("I" & c.Row).Cells.Value = "20/02/2008"
End If
End If
Next
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub

Kind Regards
Dylan Dawson

"eliano" wrote:

> Hi JLG.
>
> Tested, but my xl2003 require a With....End With to work properly.
> However many thanks.
>
> Sub IsItThere() 'by JLGWitz
> Dim c As Range
> Dim findC As Variant
>
> For Each c In ActiveSheet.Range("A2:A3000")
> If Not c Is Nothing Then
> Set findC = Worksheets(2).Cells _
> .Find(c.Value, LookIn:=xlValues)
> If Not findC Is Nothing Then
> '---
> With ActiveSheet.Range("G" & c.Row).AddComment '<-----
> .Visible = False
> .Text "Found it" '<-----
> End With
> '---
> End If
> End If
> Next
> End Sub
>
> Regards
> Eliano
>
>
>
>
> On 19 Feb, 19:55, JLGWhiz <JLGW...@discussions.microsoft.com> wrote:
> > This is untested:
> >
> > Sub IsItThere()
> > For Each c In ActiveSheet.Range("A2:A3000")
> > If Not c Is Nothing Then
> > Set findC = Worksheets(2).Cells _
> > .Find(c.Value, LookIn:=xlValues)
> > If Not findC Is Nothing Then
> > ActiveSheet.Range("G" & c.Row).AddComment _
> > .Visible = False _
> > .Text = "Found it"
> > End If
> > End If
> > Next
> > End Sub
> >
> >
> >
> > "DDawson" wrote:
> > > I want to compare the contents of a cells A2:A3000 with a column (or defined
> > > name) in another workbook. And, if a match is found, I want to enter a
> > > comment in a cell on the same row, column G of the first workbook?- Nascondi testo tra virgolette -

> >
> > - Mostra testo tra virgolette -

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Maddening Dilemma - Compare each cell within column a to each cell in column b and find unique matches pogster@gmail.com Microsoft Excel Worksheet Functions 65 16th Nov 2007 07:27 PM
Compare cell contents Peter Microsoft Excel Discussion 2 29th Sep 2006 11:48 AM
COMPARE CELL CONTENTS guy Microsoft Excel Worksheet Functions 4 24th Dec 2005 08:29 PM
compare cell contents guy Microsoft Excel Worksheet Functions 2 23rd Dec 2005 08:38 PM
Column E cell contents added into Column D contents (not overwriting data but mixing) creativetechguy Microsoft Excel Misc 2 5th Aug 2004 07:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:34 PM.