Solved

Paste Values

Posted on 2011-02-22
2
233 Views
Last Modified: 2012-06-22
Hello,

Trying to build a macro to perform the following.  I have a macro with a variable: strData = Sheets("Control").Cells(18, 2).  What I need is the find a match of strData in Sheets("Control") column "M" and once a match is found take the value from Sheets("Outlook") cells AA3, AB3, AC3, AD3 AE3 and AF3 and place them in the matching row in column O for the value of AA3, column P for the value of AB3, Column Q for the value of AC3 and so on.
0
Comment
Question by:sandramac
2 Comments
 
LVL 42

Accepted Solution

by:
dlmille earned 500 total points
ID: 34958867
Ok, simple macro to search column M for data match at control sheet row 18 column 2.  Paste AA3->AF3 into matching row, but starting in column O.

Attached code functions as requested, below.

Also see attached worksheet demonstrating effectiveness.

Enjoy!

Dave
Sub FindMatchCopyPaste()
Dim strData As Range, rFound As Range

    Set strData = Sheets("Control").Cells(18, 2)
    
    On Error Resume Next
    With Sheets("Control")
        Set rFound = .Columns("M").Find(What:=strData.Value, After:=.Cells(1, "M"), LookIn:=xlValues, LookAt:= _
            xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
            , SearchFormat:=False)
    
        On Error GoTo 0
    
        If Not rFound Is Nothing Then
            Range(.Cells(rFound.Row, "O"), .Cells(rFound.Row, "T")).Value = Range([Outlook!AA3], [Outlook!AF3]).Value
        Else
            MsgBox "Item Not Found", vbOKOnly
        End If
    End With


End Sub

Open in new window

CopyPasteExercise-r1.xlsm
0
 

Author Closing Comment

by:sandramac
ID: 34975761
Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question