troubleshooting Question

Paste Coding

Avatar of sandramac
sandramac asked on
Microsoft Excel
2 Comments1 Solution276 ViewsLast Modified:
Hello all, I got this solution from an earlier question, listed below,  trying to figure out how I would add another criteria, in the copy data line, I need it instead of pasting into A3, paste into the cell two rows below the cell that has "DTE 2" in column A.  Thanks.

Public Sub Workbook_Open()
Dim ws As Worksheet
Dim result As Range
Application.DisplayAlerts = False

    '-- open other excel file
    Set ws = Workbooks.Open("\\data\mas.xlsx").Sheets("TAC MET")
    '-- search for CAO
    Set result = ws.UsedRange.Find("CAO")
    If result Is Nothing Then MsgBox ("CAO could not be found"): End
    '-- copy data
    ws.Range("A3:G" & result.Row - 1).Copy ThisWorkbook.Sheets("TAC MET").Range("A3")

    '-- close other excel file
    Set result = Nothing
    Set ws = Nothing
  End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros