Hi Guys,
I have two workbooks, one contains ALL the data, the other contains the newest and relevant data. One is the COPY book the other is PASTE book.
I would like to write a code that says: If column B contains "Active" then copy columns A, C, and D to the other workbook.
Problems:
1: sometimes the B column returns #VALUE because it is based on a formula that tests the dates. That is why I am trying to use IFERROR
2: I don't want ALL the content of the COPY sheet. I would like the following columns: A & C:P.
Sub CopyPaste
Dim CopyFrom As Excel.Workbook
Set CopyFrom = Excel.Workbooks("CopyBook.xlsx")
Dim CopySheet As Excel.Worksheet
Set CopySheet = CopyBook.Worksheets("CopySheet")
Dim WorkRange
WorkRange = CopySheet.Cells(1).CurrentRegion.Value
'I have had succes with this code before, it should save the current selection of the IF STATEMENT as a value so that I can write (Copy WorkRange(i, A+C+D) to Destination.)
Dim i As Long
For i = 3 To UBound(WorkRa, 1)If Not WorkRange(i, 2) Is Nothing Then 'This line says that if the second column (here B) is not nothing / not black, then continue
If Not IsError(wkrngA(i, 2)) Then ' This line says that if the second column (here B) is not an error, then continue
If WorkRange(i, 2) = "Active" Then
'Print values from WorkRange(i, columns A, B and C) to PasteSheet.Cells(1,1)
End If
Next i
End Sub
I have tried for many hours, but these are all pretty new functions to me. Can somebody please help? Also, when answering, please explain the code so that I can learn more.
Sincerely,
Jacob
Bookmarks