Hi,
I have worked out code to copy paste rows from one sheet ot another, however I want to add a column to those rows with a formula to determine if they are repeats. I can't quite figure out how to work in that part. The following is the code I have that copy / pastes:
Then the formula I need to add is as follows, which I hope will tell me if the added row is a duplicate of any row above it:
I'm copying / pasting rows from columns A-P in source worksheet to A-P in destination, and would like the above formula in column Q.
Any help would be appreciated. Thanks
I have worked out code to copy paste rows from one sheet ot another, however I want to add a column to those rows with a formula to determine if they are repeats. I can't quite figure out how to work in that part. The following is the code I have that copy / pastes:
VBA Code:
Sub CopyPasteSegmentation()
'
'
Application.ScreenUpdating = False
Dim srcWS As Worksheet, desWS As Worksheet, srcWS2 As Worksheet, lRow As Long, lRow2 As Long, rg As Range, rg2 As Range
Set srcWS = Sheets("segmentation current")
Set desWS = Sheets("All YTD")
lRow = srcWS.Range("A" & srcWS.Rows.Count).End(xlUp).Row
Set rg = srcWS.Range("A2:P" & lRow)
Set srcWS2 = Sheets("BI current")
lRow2 = srcWS2.Range("A" & srcWS.Rows.Count).End(xlUp).Row
Set rg2 = srcWS2.Range("A2:P" & lRow)
With desWS
.Columns(1).NumberFormat = "m/dd/yyyy"
.Columns(9).NumberFormat = "m/dd/yyyy"
.Columns(8).NumberFormat = "m/dd/yyyy"
.Columns(10).NumberFormat = "$#,##0.00"
.Columns(11).NumberFormat = "$#,##0.00"
End With
rg.copy
desWS.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
rg2.copy
desWS.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
Then the formula I need to add is as follows, which I hope will tell me if the added row is a duplicate of any row above it:
Code:
"=IF(COUNTIFS(R2C3:R20000C3,RC3,R2C2:R20000C2,RC2,R2C1:R20000C1,""<""&RC1,R2C5:R20000C5,RC5),1,0)"
I'm copying / pasting rows from columns A-P in source worksheet to A-P in destination, and would like the above formula in column Q.
Any help would be appreciated. Thanks