Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Find value in sheet 1 and copy matching row from sheet 2

Have tried to do this myself as a macro, and using the answers others have
had, but am stuck.
I have two sheets. Both have data arranged as headers across columns, data
down rows. The information is non sequential and can't be put in to the same
order (the lists are different lengths).
What I need to do is:

Select value in Sheet 2 column A
Find value in sheet 1
If found cut cells b,c,d from sheet 2
Paste into cells c,e,f in sheet 1
Delete row in sheet 2
Loop

The result is that if sheet 1 =
A B C D E F G
1 w 1 1 1
2 x 1 2 4
3 y 2 3 3
4 z 1 3 1

And sheet 2 =
A B C D
1 x 9 6 1
2 z 7 5 2
3 r 6 8 3

Then afterwards it would read

The result is that if sheet 1 =
A B C D E F G
1 w 1 1 1
2 x 1 9 2 6 1 4
3 y 2 3 3
4 z 1 7 3 5 2 1

And sheet 2 =
A B C D
1 r 6 8 3

(As r is not on the list so wouldn't be copied across.)

(And has anyone suggested to MS that Fixed width fonts on the CSS here would
be so wonderful! Actually will do it myself as every little helps...)

Thank you in advance any and all suggestions appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Find value in sheet 1 and copy matching row from sheet 2

Sub combinesheets()

Sh2RowCount = 2
With Sheets("Sheet2")
Do While .Range("A" & Sh2RowCount) < ""
ColAData = .Range("A" & Sh2RowCount)

Set c = Sheets("Sheet1").Columns("A:A").Find( _
what:=ColAData, LookIn:=xlValues)
If Not c Is Nothing Then
c.Offset(0, 2) = .Range("B" & Sh2RowCount)
c.Offset(0, 4) = .Range("C" & Sh2RowCount)
c.Offset(0, 5) = .Range("D" & Sh2RowCount)
.Rows(Sh2RowCount).Delete
Else
Sh2RowCount = Sh2RowCount + 1
End If

Loop
End With
End Sub


"Also" wrote:

Have tried to do this myself as a macro, and using the answers others have
had, but am stuck.
I have two sheets. Both have data arranged as headers across columns, data
down rows. The information is non sequential and can't be put in to the same
order (the lists are different lengths).
What I need to do is:

Select value in Sheet 2 column A
Find value in sheet 1
If found cut cells b,c,d from sheet 2
Paste into cells c,e,f in sheet 1
Delete row in sheet 2
Loop

The result is that if sheet 1 =
A B C D E F G
1 w 1 1 1
2 x 1 2 4
3 y 2 3 3
4 z 1 3 1

And sheet 2 =
A B C D
1 x 9 6 1
2 z 7 5 2
3 r 6 8 3

Then afterwards it would read

The result is that if sheet 1 =
A B C D E F G
1 w 1 1 1
2 x 1 9 2 6 1 4
3 y 2 3 3
4 z 1 7 3 5 2 1

And sheet 2 =
A B C D
1 r 6 8 3

(As r is not on the list so wouldn't be copied across.)

(And has anyone suggested to MS that Fixed width fonts on the CSS here would
be so wonderful! Actually will do it myself as every little helps...)

Thank you in advance any and all suggestions appreciated.

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
copy matching value rows to other sheet tkraju via OfficeKB.com Excel Discussion (Misc queries) 2 June 7th 09 12:41 PM
Macro to find matching date and copy values to another sheet Tiger Excel Discussion (Misc queries) 3 August 13th 07 01:45 PM
Find value from sheet 1 on sheet 2 and copy to an offset from there L. Howard Kittle Excel Programming 3 March 2nd 07 09:32 PM
List matching data from sheet 1 in sheet 2 Thrain Excel Worksheet Functions 4 December 2nd 05 07:11 PM
how to find and copy values on sheet 2, based on a list on sheet 1 evanmacnz Excel Programming 4 February 7th 05 08:33 PM


All times are GMT +1. The time now is 01:12 PM.

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"