Record Macros - Copy & Paste Into Find Function

LaurindaS

New Member
Joined
Jan 15, 2019
Messages
15
Hi,

I’m fairly newto generating macros. I’ve been using record macros, but it’s not workingexactly the way I would like it to.

1. On tab “KIT”, select cell “O2”
2. Copy (In the example the text in O2, is “test”)
3. Go to tab “PLAN”, select column “B:B”
4. Find & paste
5. Close Find Pop-Up
6. Scroll to the left

This is what it’s recording. I’m not sure how to changethe Find “test” to Find whatever text is in cell O2.

Sheets("KIT").Select

Range("O2").Select
Selection.Copy
Sheets("PLAN").Select
Columns("B:B").Select
Selection.Find(What:="test", After:=ActiveCell,LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 11).Range("A1").Select

Any help with this would be greatly appreciated!

Thanks in advance!
Laurinda
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi & welcome to MrExcel.
How about
Code:
Sub LaurindaS()
   Dim Fnd As Range
   Sheets("Plan").Activate
   Set Fnd = Range("B:B").Find(Sheets("Kit").Range("O2").Value, , , xlPart, , , False, , False)
   If Not Fnd Is Nothing Then Fnd.Offset(, 11).Activate
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
I'm wondering if you might be able to help me out once more? I found a potential for error in my macros. What I'm doing is pasting a section beside what is found from cell O2. The issue I found is that if the text that is in O2 is not in column B:B, it pastes that section in row 1 which is my header. Is there a way I can have it paste if it is found, or give an error message if it is not found?

Dim Fnd As Range
Sheets("PLAN").Activate
Set Fnd = Range("B:B").Find(Sheets("Kit").Range("O2").Value, , , xlPart, , , False, , False)
If Not Fnd Is Nothing Then Fnd.Offset(, 11).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Thanks again,
Laurinda
 
Upvote 0
How about
Code:
Sub LaurindaS()
   Dim Fnd As Range
   
   Sheets("Plan").Activate
   Set Fnd = Range("B:B").Find(Sheets("Kit").Range("O2").Value, , , xlPart, , , False, , False)
   If Not Fnd Is Nothing Then Fnd.Offset(, 11).Value = Sheets("Kit").Range("O2").Value
End Sub
 
Upvote 0


That is almost what I'm looking for, but what I would likecopied & pasted in that section is a section of a row. I've tried thismacros and it seems to only paste the 1st cell in the section.





Dim Fnd As Range


Sheets("PLAN DATA").Activate


Set Fnd =Range("B:B").Find(Sheets("KIT").Range("O2").Value,, , xlPart, , , False, , False)


If Not Fnd Is Nothing Then Fnd.Offset(, 11).Value =Sheets("SORT").Range("A1:KI1").Value





Any ideas?



Thanks,



Laurinda













 
Upvote 0
try
Code:
   If Not Fnd Is Nothing Then Fnd.Offset(, 11).Resize(, 295).Value = Sheets("Sort").Range("A1:KI1").Value
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,720
Members
448,986
Latest member
andreguerra

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