StarvingDog
New Member
- Joined
- May 28, 2019
- Messages
- 8
VBA novice and first time poster here . I'm attempting to copy specific rows from two different sheets ("Chemistry OOS Log" and "Microbiology OOS Log") to a third sheet at which point it will be filtered based on the value in column "L". All sheets are in the same workbook. The initial ranges should only be copied if the cell value in column "O" is nothing. My code is "almost" working... It is only copying/pasting the last specified row from each sheet. I haven't started on the code to filter the "Open OOS" sheet... I'll work on that after this issue is resolved. Thank you in advance!
Code:
Sub Transfer_OOS()
Worksheets("Open OOS").Range("A2:Q100").Clear
ActiveWorkbook.Sheets("Chemistry OOS Log").Activate
Call LoopAndCopy
ActiveWorkbook.Sheets("Microbiology OOS Log").Activate
Call LoopAndCopy
End Sub
Sub LoopAndCopy()
Application.ScreenUpdating = False
Dim c As Range
Dim Last_Row As Long
Last_Row = Sheets("Open OOS").Range("A65536").End(xlUp).Row
For Each c In Range(("O2:O") & Cells(Rows.Count, "O").End(xlUp).Row)
If Not IsEmpty(c.Value) Then
Else
c.EntireRow.Copy
Sheets("Open OOS").Activate
Cells(Last_Row + 1, 1).PasteSpecial xlValues
Cells(Last_Row + 1, 1).PasteSpecial xlFormats
End If
Next c
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub