malikusmanali.awan
New Member
Good Day!
I Was facing an issue. i want to copy data from APQ sheet to APQ history, VBA code doing fine. i need code which will not copy same data twice.
following Is code.
>>> use code - tags <<<
I Was facing an issue. i want to copy data from APQ sheet to APQ history, VBA code doing fine. i need code which will not copy same data twice.
following Is code.
>>> use code - tags <<<
Code:
Sub Save_Data2()
Dim rng As Range
Dim i As Long
Dim a As Long
Dim rng_dest As Range
Application.ScreenUpdating = False
i = 1
Set rng_dest = Sheets("Invoice History").Range("E:J")
' Find first empty row in columns E:j on sheet Invoice Hsitory
Do Until WorksheetFunction.CountA(rng_dest.Rows(i)) = 0
i = i + 1
Loop
'Copy range B10:G24 on sheet APQ to Variant array
Set rng = Sheets("APQ").Range("B10:G24")
For a = 1 To rng.Rows.Count
If WorksheetFunction.CountA(rng.Rows(a)) <> 0 Then
rng_dest.Rows(i).Value = rng.Rows(a).Value
'Copy Invoice number
Sheets("Invoice History").Range("B" & i).Value = Sheets("APQ").Range("E4").Value
'Copy Date
Sheets("Invoice History").Range("A" & i).Value = Sheets("APQ").Range("H6").Value
'Copy Company name
Sheets("Invoice History").Range("C" & i).Value = Sheets("APQ").Range("D7").Value
'Copy P.O number
Sheets("Invoice History").Range("D" & i).Value = Sheets("APQ").Range("C5").Value
i = i + 1
End If
Next a
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: