Find & Replace based on a Cell Value

VanceLiving

New Member
Joined
Mar 5, 2013
Messages
45
Hi guys,

I don't work in VBA too often and have been searching for hours for, what I thought would be, a simple Find and Replace code. All I'm trying to do is search for a cell's value (located in "B8") down a column ("B14":B"). If a match is located, I was hoping to replace that matched row with row values ("B8:Z8"). If no match is found, I am hoping to simply move along.

Any ideas would be very appreciated. Thanks so much!!!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
How about
Code:
Sub VanceLiving()
   Dim Fnd As Range
   
   Set Fnd = Range("B14", Range("B" & Rows.Count).End(xlUp)).Find(Range("B8").Value, , , xlWhole, , , False, , False)
   If Not Fnd Is Nothing Then Fnd.Resize(, 25).Value = Range("B8:Z8").Value
End Sub
 
Upvote 0
Fluff - God bless you! Just for aesthetics, is there a way to incorporate the original formatting of "B8:Z8" into the code (number formats, etc.)?

Thanks again, very much appreciated!!
 
Upvote 0
How about
Code:
Sub VanceLiving()
   Dim Fnd As Range
   
   Set Fnd = Range("B14", Range("B" & Rows.Count).End(xlUp)).Find(Range("B8").Value, , , xlWhole, , , False, , False)
   If Not Fnd Is Nothing Then Range("B8:Z8").Copy Fnd
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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