I am making VBA code to find errors from one sheet and paste the values from column A and B from the row of the error to the destination sheet.
My code is pasting the error cell and the cell to the right instead of the values from A and B.
Example: imagine the macro is running all values in column K and there is an error in K85, it is pasting K85 and L85, instead of A85 and B85.
Sub Copy_NA_Values()
Dim rng As Range
Dim firstBlank As Range
Dim shtSource As Worksheet
Dim shtDestination As Worksheet
Set shtSource = ThisWorkbook.Sheets("JE Royalty detail") 'Change to the name of the source sheet
Set shtDestination = ThisWorkbook.Sheets("DB") 'Change to the name of the destination sheet
Set rng = shtSource.Range("F:F").SpecialCells(xlCellTypeFormulas, xlErrors)
For Each cell In rng
If IsError(Range("F:F")) = False Then
Set firstBlank = shtDestination.Range("K" & Rows.Count).End(xlUp).Offset(1, 0)
cell.Resize(1, 2).Copy firstBlank
End If
Next cell
End Sub
I tried paste special but I had errors.