LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default Find Feature with Macro

On Sep 16, 6:24*am, Alexander
wrote:
Hi

I have struggling with one part of my macro.

Basically, I have a row of cells with names. Alex, John, Martha, Jim, etc..
Each person has a list of data under them. I have a master column of data..
Depending who is on duty today, I want the macro to find the person and then
copy paste special the master column over the person column.

Thus, in the macro code where it says
Quote:
Find(What:="John",
I
want it to refer to a specific cell. I.e. what:=$E$4.

Then it must go to the cell it found and copy paste the info in.

Cells.Find(What:="John", After:=ActiveCell, LookIn:=xlFormulas, _
* * * * LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
* * * * MatchCase:=False, SearchFormat:=False).Activate

Any ideas on how to do this?

Regards

Alex


Alex-
The following code is based on a few assumptions. You'll have to
modify these named ranges to meet your needs. Here is how I set up my
worksheet to test:

The row of cells with names I put in row 1, starting in cell D1. The
master list started in cell I1. All their associated values are in
the cells below each name. The cell where you'll input the person's
name on duty is cell A2.

A B C
D E F
G H I
1 On Duty: Alex
John Martha Jim
Master
2 <input name 1
2 3
4 2
3
Temp Full Full
Temp Full



You'll need to establish some named ranges. For the values associated
with each name, create a named range for their list of values. For
example, create a named range called "Alex" that refers to cells
D2:D3. Don't include the field header in the named range. Do this
for all names and also create a named range for the Master list
labeled, "Master". It too should NOT contain the field header (e.g.,
I2:I3 only).

In the module folder of the workbook (Alt + F11) place the following
code:

Sub OnDuty()
Dim rng As Range
Set rng = Range("A2")

Range((rng.Value)).ClearContents
Range("Master").Copy Range((rng.Value))
End Sub

How this works: It sets the "rng" variable equal to the value in cell
A2. This is the name of the person on duty, which also corresponds to
one of the named ranges you want to replace with the values in the
Master named range. Now that you've established the appropriate named
range to replace, the next line clears the contents of that named
range, then copies the master named range into the named range that
matches what's in cell A2.

Hope this works.

Excel.Instructor (Ed2go.com/Advanced Excel)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find feature defaults to look in formulas dford Excel Discussion (Misc queries) 18 April 9th 07 01:00 AM
Find feature - Fill cells with color dford Excel Discussion (Misc queries) 8 March 12th 07 04:10 PM
where can I find the Auto Sum feature on Excel Lexus841 Excel Worksheet Functions 1 January 24th 06 10:00 PM
Copy Rows found using Find All feature Scott H Excel Discussion (Misc queries) 3 May 2nd 05 06:04 PM
how to change "Find" feature darnat2 Excel Worksheet Functions 1 November 15th 04 01:50 AM


All times are GMT +1. The time now is 03:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"