Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Find row with the same data like in another row

Hello All,

I try to learn VBA myself. But it stoped me:
Workbook A contain lot of rows. Workbook B contain one row which I need to
find in Worbook A. I try to find row in Workbook A which contain the same
data (First 20 columns contain data) like row 1 in Workbook B.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Find row with the same data like in another row

Here is one way:

Sub FindRowInOther()
Dim Y as double
Dim Y as double
Dim Found as integer
dim Dataarray(20,1) as variant
sheets("Lookfordata").select
for X=1 to 20
dataarray(x,1)=cells(activecell.row,x).value
next

sheets("lookinData").select
x=1
do while true
if cells(x,1).value=empty then exit do 'assumes nothing in column A
ends search
found=0
for Y=1 to 20
if cells(x,Y).value=dataarray(x,1) then
found=Found+1
end if
end for
if found=20 then
msgbox("Found it! on row " & x)
cells(x,1).select
Ans=1
exit do
end if
x=x+1
Loop

if Ans=0 then
msgbox("Could not find your data!")
end if

End sub

"Bartosz" wrote:

Hello All,

I try to learn VBA myself. But it stoped me:
Workbook A contain lot of rows. Workbook B contain one row which I need to
find in Worbook A. I try to find row in Workbook A which contain the same
data (First 20 columns contain data) like row 1 in Workbook B.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Find row with the same data like in another row

I made one change:
....was:
for Y=1 to 20
if cells(x,Y).value=dataarray(x,1) then


Should be: if cells(x,Y).value=dataarray(Y,1) then

Thanks anyway!!!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Find row with the same data like in another row

I think I had it right the first time I typed my initial reply. But
sometimes when i click "Post", I get a login-in screen which when I finally
remove it it says I am not authorized to upload a reply. I lose the text I
just typed and have to retype it if I forget to save the test outside of the
Message Box where I am typing this. But anyway, glad you can use it.

"Bartosz" wrote:

I made one change:
...was:
for Y=1 to 20
if cells(x,Y).value=dataarray(x,1) then


Should be: if cells(x,Y).value=dataarray(Y,1) then

Thanks anyway!!!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Find row with the same data like in another row

If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook

Sub test12()
Dim rng1 As Range, rng2 As Range, iRow As Range
Set rng1 = Sheets("A").Range("A1:D20").Rows
Set rng2 = Sheets("B").Range("A1:D1")
For Each iRow In rng1
If RowsEqual(iRow, rng2) Then
MsgBox iRow.Row
Exit For
End If
Next
End Sub

Alan Beban

Bartosz wrote:
Hello All,

I try to learn VBA myself. But it stoped me:
Workbook A contain lot of rows. Workbook B contain one row which I need to
find in Worbook A. I try to find row in Workbook A which contain the same
data (First 20 columns contain data) like row 1 in Workbook B.

Thanks



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
Find formatting doesn't work: "Excel cannot find data" Kasama Excel Discussion (Misc queries) 1 August 18th 06 01:40 PM
Despite data existing in Excel 2002 spreadsheet Find doesn't find AnnieB Excel Discussion (Misc queries) 1 June 16th 06 02:15 AM
The match and lookup functions can find literal data but not the same data referenced from a cell Jeff Melvaine Excel Discussion (Misc queries) 3 April 30th 05 01:29 PM
FIND DATA WITHIN DATA (V-OR-H LOOKUP/FIND/MATCH?) Jaladino Excel Worksheet Functions 0 February 22nd 05 11:22 PM
I need to find a macro to find data cut and paste to another colu. Rex Excel Programming 6 December 7th 04 09:22 AM


All times are GMT +1. The time now is 10:17 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"