I want to merge two tables from two different workbooks and that is what I managed to do so far.
The code I have is good to look for the rows that have active in them but it keeps empty rows in between the new table. Meaning, ID 1 and 4 are active but there is two rows non active and unknown so it wont copy them and I will have similar to the picture
Could someone help me to add a line so it does not leave an empty rows?
**Also I would like to add a line so it look for the ID in another table and copy the row and bring it to the new table.
**There are errors in the line (4 Stevens) so how can I make it report it back to me that there is error?
The code I have is good to look for the rows that have active in them but it keeps empty rows in between the new table. Meaning, ID 1 and 4 are active but there is two rows non active and unknown so it wont copy them and I will have similar to the picture
Could someone help me to add a line so it does not leave an empty rows?
**Also I would like to add a line so it look for the ID in another table and copy the row and bring it to the new table.
**There are errors in the line (4 Stevens) so how can I make it report it back to me that there is error?
VBA Code:
Option Explicit
Sub Test()
Dim Cell As Range
With Sheets(1)
' loop column H untill last cell with value (not entire column)
For Each Cell In .Range("G1:G" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If Cell.Value = "Active" Then
' Copy>>Paste in 1-line (no need to use Select)
.Rows(Cell.Row).Copy Destination:=Sheets(4).Rows(Cell.Row)
End If
Next Cell
End With
End Sub
Attachments
Last edited by a moderator: