Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default finding a specific value on a master file

Hi there,
Perhaps someone can help me with this.
I have 2 sheets in the same workbook. The first sheet called "Masterfile"
and it has all the security ids ( something like SXSF1001002) in column A.The
second sheet called "List" and it has some securities id also in column A. Is
there a way for me to check each elements in the "List" sheet against the
"Master" sheet? If there is something then say "yes" in column B of the
"List" and if not, then say "no".
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default finding a specific value on a master file

I had very similar code from a posting this morning.

Sub Duplicates()
ScreenUpdating = False

'get first empty row of sheet1

'find matching rows in sheet 2
With Sheets("Masterfile")
RowCount = 1
Do While .Range("A" & RowCount) < ""
ID = Trim(.Range("A" & RowCount))
'compare - look for ID in Sheet 2
With Sheets("List")
Set c = .Columns("A").Find(what:=ID, _
LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
End With
If c Is Nothing Then
.Range("B" & RowCount) = "No"
Else
.Range("B" & RowCount) = "Yes"
End If

RowCount = RowCount + 1
Loop
End With

ScreenUpdating = True

End Sub





"Don Doan" wrote:

Hi there,
Perhaps someone can help me with this.
I have 2 sheets in the same workbook. The first sheet called "Masterfile"
and it has all the security ids ( something like SXSF1001002) in column A.The
second sheet called "List" and it has some securities id also in column A. Is
there a way for me to check each elements in the "List" sheet against the
"Master" sheet? If there is something then say "yes" in column B of the
"List" and if not, then say "no".

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default finding a specific value on a master file

This will identify the matched items with a "Yes"
Blanks will indicate no match.

Sub ckList()
Dim lr As Long, sh1 As Worksheet, sh2 As Worksheet
Dim rng As Range
Set sh1 = Sheets("Masterfile")
Set sh2 = Sheets("List")
lr1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row
lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lr1
For j = 2 to lr2
If sh2.Cells(j, 1) = Sh1.Cells(i, 1) Then
Sh.Range("B" & j) = "Yes"
End If
Next
Next
End Sub


"Don Doan" wrote in message
...
Hi there,
Perhaps someone can help me with this.
I have 2 sheets in the same workbook. The first sheet called "Masterfile"
and it has all the security ids ( something like SXSF1001002) in column
A.The
second sheet called "List" and it has some securities id also in column A.
Is
there a way for me to check each elements in the "List" sheet against the
"Master" sheet? If there is something then say "yes" in column B of the
"List" and if not, then say "no".



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default finding a specific value on a master file

The for loop approach is much slower than using Find. You also aren't
putting th No in column B when it is not found.

"JLGWhiz" wrote:

This will identify the matched items with a "Yes"
Blanks will indicate no match.

Sub ckList()
Dim lr As Long, sh1 As Worksheet, sh2 As Worksheet
Dim rng As Range
Set sh1 = Sheets("Masterfile")
Set sh2 = Sheets("List")
lr1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row
lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lr1
For j = 2 to lr2
If sh2.Cells(j, 1) = Sh1.Cells(i, 1) Then
Sh.Range("B" & j) = "Yes"
End If
Next
Next
End Sub


"Don Doan" wrote in message
...
Hi there,
Perhaps someone can help me with this.
I have 2 sheets in the same workbook. The first sheet called "Masterfile"
and it has all the security ids ( something like SXSF1001002) in column
A.The
second sheet called "List" and it has some securities id also in column A.
Is
there a way for me to check each elements in the "List" sheet against the
"Master" sheet? If there is something then say "yes" in column B of the
"List" and if not, then say "no".




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default finding a specific value on a master file

Gives the OP something to play with. <g


"Joel" wrote in message
...
The for loop approach is much slower than using Find. You also aren't
putting th No in column B when it is not found.

"JLGWhiz" wrote:

This will identify the matched items with a "Yes"
Blanks will indicate no match.

Sub ckList()
Dim lr As Long, sh1 As Worksheet, sh2 As Worksheet
Dim rng As Range
Set sh1 = Sheets("Masterfile")
Set sh2 = Sheets("List")
lr1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row
lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lr1
For j = 2 to lr2
If sh2.Cells(j, 1) = Sh1.Cells(i, 1) Then
Sh.Range("B" & j) = "Yes"
End If
Next
Next
End Sub


"Don Doan" wrote in message
...
Hi there,
Perhaps someone can help me with this.
I have 2 sheets in the same workbook. The first sheet called
"Masterfile"
and it has all the security ids ( something like SXSF1001002) in column
A.The
second sheet called "List" and it has some securities id also in column
A.
Is
there a way for me to check each elements in the "List" sheet against
the
"Master" sheet? If there is something then say "yes" in column B of the
"List" and if not, then say "no".








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default finding a specific value on a master file

This should work to include the "No" in col. B.

Sub ckList()
Dim lr As Long, sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Sheets("Masterfile")
Set sh2 = Sheets("List")
lr1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row
lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
For Each c In sh2.Range("A2:A" & lr2)
For i = 1 To lr1
If c = sh1.Cells(i, 1) Then
c.Offset(, 1) = "Yes"
Exit For
Else
c.Offset(, 1) = "No"
End If
Next
Next
End Sub


"Joel" wrote in message
...
The for loop approach is much slower than using Find. You also aren't
putting th No in column B when it is not found.

"JLGWhiz" wrote:

This will identify the matched items with a "Yes"
Blanks will indicate no match.

Sub ckList()
Dim lr As Long, sh1 As Worksheet, sh2 As Worksheet
Dim rng As Range
Set sh1 = Sheets("Masterfile")
Set sh2 = Sheets("List")
lr1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row
lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lr1
For j = 2 to lr2
If sh2.Cells(j, 1) = Sh1.Cells(i, 1) Then
Sh.Range("B" & j) = "Yes"
End If
Next
Next
End Sub


"Don Doan" wrote in message
...
Hi there,
Perhaps someone can help me with this.
I have 2 sheets in the same workbook. The first sheet called
"Masterfile"
and it has all the security ids ( something like SXSF1001002) in column
A.The
second sheet called "List" and it has some securities id also in column
A.
Is
there a way for me to check each elements in the "List" sheet against
the
"Master" sheet? If there is something then say "yes" in column B of the
"List" and if not, then say "no".






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default finding a specific value on a master file

Thank you both for helping out....the codes work great!!!!! :)

"JLGWhiz" wrote:

This should work to include the "No" in col. B.

Sub ckList()
Dim lr As Long, sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Sheets("Masterfile")
Set sh2 = Sheets("List")
lr1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row
lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
For Each c In sh2.Range("A2:A" & lr2)
For i = 1 To lr1
If c = sh1.Cells(i, 1) Then
c.Offset(, 1) = "Yes"
Exit For
Else
c.Offset(, 1) = "No"
End If
Next
Next
End Sub


"Joel" wrote in message
...
The for loop approach is much slower than using Find. You also aren't
putting th No in column B when it is not found.

"JLGWhiz" wrote:

This will identify the matched items with a "Yes"
Blanks will indicate no match.

Sub ckList()
Dim lr As Long, sh1 As Worksheet, sh2 As Worksheet
Dim rng As Range
Set sh1 = Sheets("Masterfile")
Set sh2 = Sheets("List")
lr1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row
lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lr1
For j = 2 to lr2
If sh2.Cells(j, 1) = Sh1.Cells(i, 1) Then
Sh.Range("B" & j) = "Yes"
End If
Next
Next
End Sub


"Don Doan" wrote in message
...
Hi there,
Perhaps someone can help me with this.
I have 2 sheets in the same workbook. The first sheet called
"Masterfile"
and it has all the security ids ( something like SXSF1001002) in column
A.The
second sheet called "List" and it has some securities id also in column
A.
Is
there a way for me to check each elements in the "List" sheet against
the
"Master" sheet? If there is something then say "yes" in column B of the
"List" and if not, then say "no".






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
Extract specific data from multiple workbooks to a master file Esposa Excel Programming 2 November 3rd 08 11:12 PM
How do I copy specific information from a master sheet? PFAA Excel Worksheet Functions 1 July 22nd 08 05:31 PM
Finding selected numbers within a master list JennaB Excel Worksheet Functions 2 July 9th 08 06:06 PM
finding specific values in a within a file gerry405 New Users to Excel 0 November 14th 05 02:08 PM
Copy and pasting specific sheet data to a master worksheet simora Excel Programming 4 May 9th 05 05:30 AM


All times are GMT +1. The time now is 04:53 AM.

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

About Us

"It's about Microsoft Excel"