I am new to VBA so I need to copy rows from one sheet into another only if value is missing in first. The cells format stay same always. For now I have this code:
Sub test()
Dim tohere As Worksheet
Dim fromhere As Worksheet
Dim rngTohere As Range
Dim rngfromHere As Range
Dim rngCelTohere As Range
Dim count As Integer
Dim strArray As Variant
Dim i As Integer
'Set Workbooks
Set tohere = ThisWorkbook.Worksheets("Test")
Set fromhere = ThisWorkbook.Worksheets("Test 2")
'Set Columns
Set rngTohere = tohere.Columns("C") 'this is our column of interest
Set rngfromHere = fromhere.Columns("C")
i = 1 'this is counter to foryou to know which row you need to copy
count = rngfromHere.Cells.Count - WorksheetFunction.CountBlank(rngfromHere)
strArray = rngfromHere(Cells(1, 1), Cells(count, 1)).Value
'Loop through each cell in Column C
For Each rngCelTohere In rngTohere.Cells
If IsInArray(rngCelTohere.Value, strArray) = False Then
'here need to put copy entire row into sheet
'use i row to copy into tohere Worksheet
End If
i = i + 1 '
Next rngCelTohere
End Sub
Function IsInArray(stringToBeFound As Integer, arr As Variant) As Boolean 'this functions returns true or false. for our case we need it to be false
IsInArray = (UBound(Filter(arr, stringToBeFound)) > -1)
End Function
Can anyone help me and say if this is good idea, and also help me with copy entire row at the end of sheet. Thanks in advance!