Using FIND to copy and paste....

chefdt

Board Regular
Joined
Jul 1, 2008
Messages
163
I want to copy a cell from an active sheet to a summary sheet using FIND. Just not hitting it yet.

I found some code from DeBruin that may get me started.

Once I copy the cell in the active sheet I want to scan a SUMMARY sheet where my value from the active sheet will be in Column A. Once it hits a match, I want to paste the value to a specific Column in that row where FIND made the match.




DT
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Where is the cell you want to copy in the active sheet? How do you decide which cell to copy?
 
Upvote 0
It will always be in J1

Summary sheet should have the activesheet name somewhere in Column A.
 
Upvote 0
Try this macro:
Code:
Sub CopyCell()
    Application.ScreenUpdating = False
    Dim foundVal As Range
    Set foundVal = Sheets("Sheet2").Range("A:A").Find(Sheets("Sheet1").Range("J5"), LookIn:=xlValues, lookat:=xlWhole)
    If Not foundVal Is Nothing Then
        Sheets("Sheet2").Cells(foundVal.Row, "B") = Sheets("Sheet1").Range("J5")
    Else
        MsgBox ("Value not found.")
    End If
    Application.ScreenUpdating = True
End Sub
You didn't specify into which column of Sheet2 you wanted to paste. The code pastes to column B. If you want to paste to a different column, change the "B" in this line:
Code:
Sheets("Sheet2").Cells(foundVal.Row, "B") = Sheets("Sheet1").Range("J5")
to whichever column you want to paste.
 
Upvote 0
Ultimately I will have this looping through all sheets and will need to change "Sheet1" to activesheet.

Would it be - find(sheets.activesheet.range("J5"), LookIn:=xlValues ?



Try this macro:
Code:
Sub CopyCell()
    Application.ScreenUpdating = False
    Dim foundVal As Range
    Set foundVal = Sheets("Sheet2").Range("A:A").Find(Sheets("Sheet1").Range("J5"), LookIn:=xlValues, lookat:=xlWhole)
    If Not foundVal Is Nothing Then
        Sheets("Sheet2").Cells(foundVal.Row, "B") = Sheets("Sheet1").Range("J5")
    Else
        MsgBox ("Value not found.")
    End If
    Application.ScreenUpdating = True
End Sub
You didn't specify into which column of Sheet2 you wanted to paste. The code pastes to column B. If you want to paste to a different column, change the "B" in this line:
Code:
Sheets("Sheet2").Cells(foundVal.Row, "B") = Sheets("Sheet1").Range("J5")
to whichever column you want to paste.
 
Upvote 0
Will cell J5 in all the sheets ever have duplicate values?
 
Upvote 0

Forum statistics

Threads
1,216,124
Messages
6,128,990
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top