Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Paste Values

Posted on 2011-02-22
2
Medium Priority
?
238 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 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