sandramac
asked on
Paste Coding
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").Sh eets("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
ws.Parent.Close
Set ws = Nothing
End Sub
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
'-- 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
ws.Parent.Close
Set ws = Nothing
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Set dst = ThisWorkbook.Sheets("TAC MET").UsedRange.Find("DTE 2")
If dst Is Nothing Then MsgBox ("DTE 2 could not be found"): End
Then change the copy line to
ws.Range("A3:G" & result.Row - 1).Copy dst.Offset(0,3)