ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy cell value to new worksheet, based on find results (https://www.excelbanter.com/excel-programming/364723-copy-cell-value-new-worksheet-based-find-results.html)

dan

Copy cell value to new worksheet, based on find results
 
I have a spreadsheet with a few columns. Sheet 1, Column A contains
numbers. Sheet 2, Column A contains the same numbers, just in different
order. I want to be able to say something like - if value in A5 = 32,
copy value the value in D5 and paste it into Sheet 2 where the value in
column A is 32. I want Sheet 2 to have only the values of column A and
Column D.

Thanks in advance!


Celt[_78_]

Copy cell value to new worksheet, based on find results
 

Dan,

not sure if you specifically want to use VBA to do this...but you ca
use a formula.

Assume that in Sheet 1 column A you have a range of numbers and Sheet
column D you have a range of numbers. If I understand, based on th
value in a cell in column A, you want to copy the value in column D o
that same row, to sheet 2 and place on (in column D ??) on the same ro
as the cell in sheet 2 column A having the same number as sheet1 colum
A.

kind of wordy...but right?

you can use this formula:

=SUMPRODUCT(--(EXACT(Sheet1!$A$1:$A$30,$A1)),Sheet1!$D$1:$D$30)

if sheet 1 cols A and D are populated..and column A sheet 2 i
populated, then all you need to do is copy this formula into col D o
sheet 2 and copy down.

you may need to adjust the searched range (ie. $A$1:$A$30 and $D1:$D30
to fit your data.

this worked fine for me when I tested it, however on a side note if
cell in sheet 2 col A matches more than one cell in sheet 1 col A, thi
formula will sum those two numbers together and place them in sheet
col D.

HT

--
Cel
-----------------------------------------------------------------------
Celt's Profile: http://www.excelforum.com/member.php...fo&userid=1941
View this thread: http://www.excelforum.com/showthread.php?threadid=55332


Otto Moehrbach

Copy cell value to new worksheet, based on find results
 
Dan
This macro will do that. Note that Sheet1 has to be the active sheet
and your Sheet2 is named "Two" in this macro. Change that to suit your
actual data.
HTH Otto
Sub CopyNums()
Dim OneColA As Range 'Column A in Sheet1
Dim TwoColA As Range 'Column A in sheet "Two"
Dim i As Range
Set OneColA = Range("A1", Range("A" & Rows.Count).End(xlUp))
With Sheets("Two")
Set TwoColA = .Range("A1", .Range("A" & Rows.Count).End(xlUp))
For Each i In OneColA
If Not TwoColA.Find(What:=i.Value, LookAt:=xlWhole) Is Nothing
Then _
TwoColA.Find(What:=i.Value, LookAt:=xlWhole).Offset(, 1) = _
i.Offset(, 3).Value
Next i
End With
End Sub
"dan" wrote in message
ups.com...
I have a spreadsheet with a few columns. Sheet 1, Column A contains
numbers. Sheet 2, Column A contains the same numbers, just in different
order. I want to be able to say something like - if value in A5 = 32,
copy value the value in D5 and paste it into Sheet 2 where the value in
column A is 32. I want Sheet 2 to have only the values of column A and
Column D.

Thanks in advance!





All times are GMT +1. The time now is 10:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com