I have a workbook called 'EvaluationLog.xlsm' and I need to transfer specific cells (not the whole row) from the first worksheet to another existing workbook called 'IndicatorLog.xlsm' located in the same directory. The target worksheet is also the first one. I'm trying to have the macro hosted in the 'IndicatorLog' workbook.
Specific cells in each row from the source are only to be copied if the contents in column 'O' is 'No' or if the contents of column 'J' is 'Initial'. The actual source data starts on row 8 and the target range also starts on row 8.
I've never had to code in VBA before except for a few very simple tasks, so I'm stuck.
Any help will be greatly appreciated! :)
Sub MergeFromLog()
Dim TargetSheet As Worksheet
Dim FolderPath As String
Dim NRow As Long
Dim SourceFileName As String
Dim WorkBk As Workbook
Dim LastRow As Integer, i As Integer, erow As Integer
' Set destination file.
Set TargetSheet = ActiveWorkbook.Worksheets(1)
' Modify this folder path to point to the files you want to use as source.
FolderPath = ""
' Set source file.
SourceFileName = FolderPath & "2015-2016 Evaluation Log.xlsm"
' NRow keeps track of where to insert new rows in the destination workbook.
NRow = 8
' Open the source workbook in the folder
Set WorkBk = Workbooks.Open(SourceFileName)
LastRow = WorkBk.ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For i = 8 To LastRow
If WorkBk.Range(“O” & i) = "No" Or WorkBk.Range(“J” & i) = “Initial” Then
' Copy Student Name
TargetSheet.Range("A" & NRow).Value = WorkBk.Range(“A” & i).Value
' Copy DOB
TargetSheet.Range("B" & NRow).Value = WorkBk.Range(“C” & i).Value
' Copy ID#
TargetSheet.Range("C" & NRow).Value = WorkBk.Range(“D” & i).Value
' Copy Consent Day
TargetSheet.Range("D" & NRow).Value = WorkBk.Range(“L” & i).Value
' Copy Report Day
TargetSheet.Range("E" & NRow).Value = WorkBk.Range(“N” & i).Value
' Copy FIE within District Timelines?
TargetSheet.Range("F" & NRow).Value = WorkBk.Range(“O” & i).Value
' Copy Qualified?
TargetSheet.Range("H" & NRow).Value = WorkBk.Range(“A” & i).Value
' Copy Primary Eligibility
TargetSheet.Range("I" & NRow).Value = WorkBk.Range(“U” & i).Value
' Copy ARD Date
TargetSheet.Range("J" & NRow).Value = WorkBk.Range(“R” & i).Value
' Copy ARD within District Timelines?
TargetSheet.Range("K" & NRow).Value = WorkBk.Range(“S” & i).Value
' Copy Ethnicity
TargetSheet.Range("M" & NRow).Value = WorkBk.Range(“F” & i).Value
' Copy Hisp?
TargetSheet.Range("N" & NRow).Value = WorkBk.Range(“G” & i).Value
' Copy Diag/LSSP
TargetSheet.Range("O" & NRow).Value = WorkBk.Range(“X” & i).Value
NRow = NRow + 1
End If
Next i
End Sub