Soulidarity
New Member
- Joined
- Feb 18, 2020
- Messages
- 2
- Office Version
- 2010
- Platform
- Windows
Hi All,
Please be patient with me, I am a novice with VBA. I am trying to use the following code to check if a cell in the current workbook = a cell in another workbook (which is open) then if it does, carry out a copy and paste function. I can do this easily if the data is in one spreadsheet but I have never done it before where it involves another spreadsheet. Any help would be greatly appreciated.
Thank you in advance!
Please be patient with me, I am a novice with VBA. I am trying to use the following code to check if a cell in the current workbook = a cell in another workbook (which is open) then if it does, carry out a copy and paste function. I can do this easily if the data is in one spreadsheet but I have never done it before where it involves another spreadsheet. Any help would be greatly appreciated.
VBA Code:
Dim Path1 As String
Dim myfilename As String
Path1 = Range("I4")
Path2 = Range("E6")
myfilename = Range("I5")
Workbooks.Open Filename:=Path1 & "" & Path2 & myfilename
ThisWorkbook.Activate
Application.ScreenUpdating = False
'CC 1 January
If (Range("E5") =[B] Cell in the workbook opened above[/B]) And (Range("E3") = "January") Then
'Copy data
Sheet1.Select
Range("E155").Select
Selection.Copy
'Paste data
Workbooks("Master PCA SPB Tracker").Activate
Sheet2.Select
Range("B16").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Thank you in advance!