Need help making a Macro to find and replace

dbouton

New Member
Joined
Mar 28, 2014
Messages
19
Hi. I am needing assistance in creating a macro to find and replace contents of cells from one sheet to another. Sheet 1 contains the data I want to put into Sheet 2. Sheet 1, in short, contains a schedule for a person. I want to find in the log list of schedules in Sheet 2 the schedule for the person (Name is in Sheet 1, Cell A5) and replace their record in Sheet 2 with what is in Sheet 1. Can someone assist, please. I am just learning Macros and cannot figure it out.

Sheet 1, Row 5 A through P

NameTitle8:0012:008:0012:008:0012:008:0012:008:0012:00OFFOFFOFFOFF

<tbody>
</tbody>


Sheet 2, A through P
Some NameTitle8:0012:008:0012:008:0012:008:0012:008:0012:00OFFOFFOFFOFF
Some Other NameTitle9:0013:009:0013:00OFFOFFOFFOFFOFFOFFOFFOFFOFFOFF
NameTitle8:0012:00OFFOFFOFFOFFOFFOFFOFFOFFOFFOFFOFFOFF

<tbody>
</tbody>

^ Lets just say that the third row above is what I want to replace with Sheet 1, Row 5 B through P, but it can be anywhere in the list.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi,
Try this out under a command button.
Dim rng As Range
For Each rng In Sheets(2).Range("B5:B1000").Cells
If rng.Value = Sheets(1).Range("B5").Value Then
Sheets(2).Range("D" & rng.Row & ":P" & rng.Row).Value = Sheets(1).Range("D5:P5").Value
End If
Next
MsgBox "Done!", vbInformation

Regards.
Karim
 
Upvote 0
Hmm... this doesnt work. All that happens is the "Done" information box pops open. When I check Sheet 2, nothing has changed...
 
Upvote 0
I am not sure you are doing the right thing.
This code expects the following:
In sheet1, Cell B5 contains the Person's name,C5 its title, D5:P5 contain its schedule.
In Sheet2, Range B5 Thru B1000 Contain the list of all your people, Column C their respective Titles, Columns D thru P their respective schedules.
So if you use this exact layout to begin with, then you will certainly get the good thing done at your discretion.

NB: Pay attention to the names of your worksheets (Sheet1 and Sheet2 in the code).

Regards.
Karim
 
Upvote 0
This code expects the following:
In sheet1, Cell B5 contains the Person's name,C5 its title, D5:P5 contain its schedule.
In Sheet2, Range B5 Thru B1000 Contain the list of all your people, Column C their respective Titles, Columns D thru P their respective schedules.
So if you use this exact layout to begin with, then you will certainly get the good thing done at your discretion.

Ahh, I have it working now. My issue was not with your module but rather with my placement of the cells. I have names in "A"... I adjusted the module as such and it is working like a champion! Now my users can update schedules without touching my master list of schedules!

Thank you very much.
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,794
Members
449,468
Latest member
AGreen17

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