SOLVED

is there a way to make sure my macro doesn't duplicate data

%3CLINGO-SUB%20id%3D%22lingo-sub-3373652%22%20slang%3D%22en-US%22%3Eis%20there%20a%20way%20to%20make%20sure%20my%20macro%20doesn't%20duplicate%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3373652%22%20slang%3D%22en-US%22%3E%3CP%3EI%20posted%20in%20another%20blog%20and%20haven't%20received%20a%20response%20so%20I%20am%20not%20sure%20that%20what%20I%20am%20asking%20can%20be%20done.%26nbsp%3B%20%26nbsp%3BI%20used%20code%20from%20the%20following%20article%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2Fapi%2Fexcel.range.copy%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2Fapi%2Fexcel.range.copy%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20partially%20accomplish%20my%20goal%20but%20I%20have%20a%20few%20more%20questions.%3C%2FP%3E%3CP%3EI%20have%20a%20file%20where%20I%20dump%20data%20every%20month%20and%20then%20extrapolate%20data%20on%20other%20tabs.%20Within%20that%20file%2C%20I%20have%20a%20%22master%22%20sheet%20where%20I%20do%20the%20data%20dump%20and%20I%20was%20able%20to%20copy%20the%20macro%20from%20the%20article%20above%20and%20amend%20it%20to%20send%20data%20based%20on%20data%20in%20a%20specific%20column%20(TERR)%20to%20a%20variety%20of%20sheets.%20What%20I%20need%20to%20accomplish%20is%20this%20-%20I%20would%20like%20to%20continue%20adding%20to%20the%20same%20sheets%20each%20month%20but%20if%20I%20run%20the%20macro%2C%20it%20will%20keep%20adding%20all%20of%20the%20same%20data%20every%20time%20(in%20other%20words%2C%20I%20don't%20want%20it%20to%20add%20the%20previously%20added%20data%20every%20time%20I%20add%20new%20data%20to%20the%20master%20sheet%20and%20then%20run%20the%20macro).%20Is%20there%20a%20way%20to%20add%20to%20the%20macro%20so%20that%20it%20does%20not%20add%20duplicate%20rows%3F%20I%20could%20use%20a%20combination%20of%20two%20other%20columns%20(Item%20and%20Invoice)%20to%20look%20at%20whether%20or%20not%20the%20data%20is%20duplicate.%20Also%2C%20there%20are%20columns%20of%20data%20that%20have%20formulas%20in%20them%20and%20when%20I%20paste%20the%20data%20to%20my%20other%20sheets%2C%20I%20would%20like%20to%20paste%20special%20values%20instead%20of%20the%20formula.%20The%20goal%20is%20that%20I%20can%20then%20sort%20and%20filter%20the%20data%20on%20the%20other%20sheets%20in%20a%20variety%20of%20ways%20and%20give%20that%20information%20to%20other%20people.%20Thanks%20for%20your%20help!!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CSPAN%20class%3D%22%22%3EPublic%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3ESub%3C%2FSPAN%3E%20CopyRows()%0A%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22MORSE%20Item%20Sales%20Analysis%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20FinalRow%20%3D%20Cells(Rows.Count%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3EEnd%3C%2FSPAN%3E(xlUp).Row%0A%20%20%20%20%3CSPAN%20class%3D%22%22%3EFor%3C%2FSPAN%3E%20x%20%3D%20%3CSPAN%20class%3D%22%22%3E2%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3ETo%3C%2FSPAN%3E%20FinalRow%0A%20%20%20%20%20%20%20%20ThisValue%20%3D%20Cells(x%2C%20%3CSPAN%20class%3D%22%22%3E29%3C%2FSPAN%3E).Value%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22%22%3EIf%3C%2FSPAN%3E%20ThisValue%20%3D%20%3CSPAN%20class%3D%22%22%3E%22FORN%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3EThen%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(x%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).Resize(%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22%22%3E48%3C%2FSPAN%3E).Copy%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22FORN%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20NextRow%20%3D%20Cells(Rows.Count%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3EEnd%3C%2FSPAN%3E(xlUp).Row%20%2B%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(NextRow%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20ActiveSheet.Paste%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22MORSE%20Item%20Sales%20Analysis%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22%22%3EElseIf%3C%2FSPAN%3E%20ThisValue%20%3D%20%3CSPAN%20class%3D%22%22%3E%22GRLK%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3EThen%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(x%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).Resize(%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22%22%3E48%3C%2FSPAN%3E).Copy%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22GRLK%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20NextRow%20%3D%20Cells(Rows.Count%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3EEnd%3C%2FSPAN%3E(xlUp).Row%20%2B%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(NextRow%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20ActiveSheet.Paste%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22MORSE%20Item%20Sales%20Analysis%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22%22%3EElseIf%3C%2FSPAN%3E%20ThisValue%20%3D%20%3CSPAN%20class%3D%22%22%3E%22NEST%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3EThen%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(x%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).Resize(%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22%22%3E48%3C%2FSPAN%3E).Copy%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22NEST%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20NextRow%20%3D%20Cells(Rows.Count%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3EEnd%3C%2FSPAN%3E(xlUp).Row%20%2B%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(NextRow%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20ActiveSheet.Paste%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22MORSE%20Item%20Sales%20Analysis%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22%22%3EElseIf%3C%2FSPAN%3E%20ThisValue%20%3D%20%3CSPAN%20class%3D%22%22%3E%22NWST%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3EThen%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(x%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).Resize(%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22%22%3E48%3C%2FSPAN%3E).Copy%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22NWST%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20NextRow%20%3D%20Cells(Rows.Count%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3EEnd%3C%2FSPAN%3E(xlUp).Row%20%2B%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(NextRow%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20ActiveSheet.Paste%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22MORSE%20Item%20Sales%20Analysis%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22%22%3EElseIf%3C%2FSPAN%3E%20ThisValue%20%3D%20%3CSPAN%20class%3D%22%22%3E%22PLNS%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3EThen%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(x%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).Resize(%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22%22%3E48%3C%2FSPAN%3E).Copy%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22PLNS%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20NextRow%20%3D%20Cells(Rows.Count%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3EEnd%3C%2FSPAN%3E(xlUp).Row%20%2B%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(NextRow%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20ActiveSheet.Paste%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22MORSE%20Item%20Sales%20Analysis%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22%22%3EElseIf%3C%2FSPAN%3E%20ThisValue%20%3D%20%3CSPAN%20class%3D%22%22%3E%22NEST%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3EThen%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(x%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).Resize(%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22%22%3E48%3C%2FSPAN%3E).Copy%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22NEST%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20NextRow%20%3D%20Cells(Rows.Count%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3EEnd%3C%2FSPAN%3E(xlUp).Row%20%2B%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(NextRow%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20ActiveSheet.Paste%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22MORSE%20Item%20Sales%20Analysis%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22%22%3EElseIf%3C%2FSPAN%3E%20ThisValue%20%3D%20%3CSPAN%20class%3D%22%22%3E%22NWST%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3EThen%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(x%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).Resize(%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22%22%3E48%3C%2FSPAN%3E).Copy%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22NWST%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20NextRow%20%3D%20Cells(Rows.Count%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3EEnd%3C%2FSPAN%3E(xlUp).Row%20%2B%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(NextRow%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20ActiveSheet.Paste%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheets(%3CSPAN%20class%3D%22%22%3E%22MORSE%20Item%20Sales%20Analysis%22%3C%2FSPAN%3E).%3CSPAN%20class%3D%22%22%3ESelect%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22%22%3EEnd%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3EIf%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22%22%3ENext%3C%2FSPAN%3E%20x%0A%3CSPAN%20class%3D%22%22%3EEnd%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3ESub%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3373652%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3373956%22%20slang%3D%22en-US%22%3ERe%3A%20is%20there%20a%20way%20to%20make%20sure%20my%20macro%20doesn't%20duplicate%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3373956%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1389955%22%20target%3D%22_blank%22%3E%40Suzanne25811%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20give%20this%20a%20try%20and%20see%20if%20this%20works%20for%20you...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-visual-basic%22%3E%3CCODE%3ESub%20CopyRows()%0A%20%20%20%20Dim%20wsSource%20%20%20%20As%20Worksheet%0A%20%20%20%20Dim%20wsDest%20%20%20%20%20%20As%20Worksheet%0A%20%20%20%20Dim%20shArr%20%20%20%20%20%20%20As%20Variant%0A%20%20%20%20Dim%20sh%20%20%20%20%20%20%20%20%20%20As%20Variant%0A%20%20%20%20Dim%20FinalRow%20%20%20%20As%20Long%0A%20%20%20%20Dim%20NextRow%20%20%20%20%20As%20Long%0A%20%20%20%20%0A%20%20%20%20Application.ScreenUpdating%20%3D%20False%0A%20%20%20%20%0A%20%20%20%20Set%20wsSource%20%3D%20ThisWorkbook.Worksheets(%22MORSE%20Item%20Sales%20Analysis%22)%0A%20%20%20%20wsSource.AutoFilterMode%20%3D%20False%0A%20%20%20%20FinalRow%20%3D%20wsSource.Cells(Rows.Count%2C%201).End(xlUp).Row%0A%20%20%20%20%0A%20%20%20%20shArr%20%3D%20Array(%22FORN%22%2C%20%22GRLK%22%2C%20%22NEST%22%2C%20%22NWST%22%2C%20%22PLNS%22)%0A%20%20%20%20%0A%20%20%20%20With%20wsSource.Range(%22A1%22).CurrentRegion%0A%20%20%20%20%20%20%20%20For%20Each%20sh%20In%20shArr%0A%20%20%20%20%20%20%20%20%20%20%20%20.AutoFilter%20field%3A%3D29%2C%20Criteria1%3A%3Dsh%0A%20%20%20%20%20%20%20%20%20%20%20%20If%20.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count%20%26gt%3B%201%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Set%20wsDest%20%3D%20ThisWorkbook.Worksheets(sh)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wsDest.Range(%22A1%22).CurrentRegion.Offset(1).ClearContents%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wsSource.Range(%22A2%3AAB%22%20%26amp%3B%20FinalRow).SpecialCells(xlCellTypeVisible).Copy%20wsDest.Range(%22A2%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20Next%20sh%0A%20%20%20%20End%20With%0A%20%20%20%20wsSource.AutoFilterMode%20%3D%20False%20%20%20%20%0A%20%20%20%20Application.ScreenUpdating%20%3D%20True%20%20%20%20%0A%20%20%20%20MsgBox%20%22Task%20Completed!%22%2C%20vbInformation%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3381227%22%20slang%3D%22en-US%22%3ERe%3A%20is%20there%20a%20way%20to%20make%20sure%20my%20macro%20doesn't%20duplicate%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3381227%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3Bthank%20you%20for%20your%20help.%26nbsp%3B%20Do%20I%20insert%20this%20after%20all%20of%20the%20code%20I%20showed%20in%20my%20message%20or%20do%20I%20need%20to%20insert%20this%20for%20each%20section%20I%20reference%20in%20the%20code%3F%26nbsp%3B%20Once%20I%20know%20what%20to%20do%20with%20it%2C%20I%20will%20follow%20up%20to%20let%20you%20know%20how%20it%20works.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20appreciate%20you!%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3381741%22%20slang%3D%22en-US%22%3ERe%3A%20is%20there%20a%20way%20to%20make%20sure%20my%20macro%20doesn't%20duplicate%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3381741%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1389955%22%20target%3D%22_blank%22%3E%40Suzanne25811%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJust%20replace%20your%20existing%20code%20with%20the%20proposed%20code%20and%20see%20if%20that%20works%20for%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3382195%22%20slang%3D%22en-US%22%3ERe%3A%20is%20there%20a%20way%20to%20make%20sure%20my%20macro%20doesn't%20duplicate%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3382195%22%20slang%3D%22en-US%22%3EIt%20worked%20in%20my%20test%20file!!!%20Thank%20you%20SO%20much!!!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3384145%22%20slang%3D%22en-US%22%3ERe%3A%20is%20there%20a%20way%20to%20make%20sure%20my%20macro%20doesn't%20duplicate%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3384145%22%20slang%3D%22en-US%22%3EYou're%20welcome!%20Glad%20it%20worked%20as%20desired.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3388204%22%20slang%3D%22en-US%22%3ERe%3A%20is%20there%20a%20way%20to%20make%20sure%20my%20macro%20doesn't%20duplicate%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3388204%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGood%20morning!%3C%2FP%3E%3CP%3EYesterday%2C%20I%20added%20a%20couple%20more%20territories.%26nbsp%3B%20Adding%20the%20territories%20worked%2C%20I%20ran%20the%20macro%20and%20it%20added%20the%20info%20to%20the%20appropriate%20tabs.%26nbsp%3B%20%26nbsp%3BThen%20I%20noticed%20that%20I%20was%20missing%26nbsp%3Bcolumns%20at%20the%20end%20-%20when%20I%20originally%20started%20this%20there%20were%2029%20columns%20and%20we%20have%20added%20more%20so%20the%20sheet%20is%20now%2045%20columns%20wide.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20morning%20I%20updated%20the%20macro%20to%20reflect%2045%20columns.%26nbsp%3B%20I%20tried%20re-running%20the%20macro%20but%20it%20did%20not%20add%20the%20%22missing%22%20info.%26nbsp%3B%20I%20deleted%20the%20information%20off%20the%20tabs%2C%20saved%20the%20file%2C%20and%20re-ran%20the%20macro%20again%20but%20nothing%20at%20all%20transferred%20to%20my%20other%20sheets%20FORN%2C%20GRLK%2C%20NEST%2C%20etc.%26nbsp%3B%20Can%20you%20help%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESub%20CopyRows()%3CBR%20%2F%3EDim%20wsSource%20As%20Worksheet%3CBR%20%2F%3EDim%20wsDest%20As%20Worksheet%3CBR%20%2F%3EDim%20shArr%20As%20Variant%3CBR%20%2F%3EDim%20sh%20As%20Variant%3CBR%20%2F%3EDim%20FinalRow%20As%20Long%3CBR%20%2F%3EDim%20NextRow%20As%20Long%3CBR%20%2F%3E%3CBR%20%2F%3EApplication.ScreenUpdating%20%3D%20False%3CBR%20%2F%3E%3CBR%20%2F%3ESet%20wsSource%20%3D%20ThisWorkbook.Worksheets(%22MORSE%20Item%20Sales%20Analysis%22)%3CBR%20%2F%3EwsSource.AutoFilterMode%20%3D%20False%3CBR%20%2F%3EFinalRow%20%3D%20wsSource.Cells(Rows.Count%2C%201).End(xlUp).Row%3CBR%20%2F%3E%3CBR%20%2F%3EshArr%20%3D%20Array(%22FORN%22%2C%20%22GRLK%22%2C%20%22NEST%22%2C%20%22NWST%22%2C%20%22PLNS%22%2C%20%22SEST%22%2C%20%22SWST%22%2C%20%22WCAN%22%2C%20%22ECAN%22)%3CBR%20%2F%3E%3CBR%20%2F%3EWith%20wsSource.Range(%22A1%22).CurrentRegion%3CBR%20%2F%3EFor%20Each%20sh%20In%20shArr%3CBR%20%2F%3E.AutoFilter%20field%3A%3D46%2C%20Criteria1%3A%3Dsh%3CBR%20%2F%3EIf%20.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count%20%26gt%3B%201%20Then%3CBR%20%2F%3ESet%20wsDest%20%3D%20ThisWorkbook.Worksheets(sh)%3CBR%20%2F%3EwsDest.Range(%22A1%22).CurrentRegion.Offset(1).ClearContents%3CBR%20%2F%3EwsSource.Range(%22A2%3AAS%22%20%26amp%3B%20FinalRow).SpecialCells(xlCellTypeVisible).Copy%20wsDest.Range(%22A2%22)%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3ENext%20sh%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3EwsSource.AutoFilterMode%20%3D%20False%3CBR%20%2F%3EApplication.ScreenUpdating%20%3D%20True%3CBR%20%2F%3EMsgBox%20%22Task%20Completed!%22%2C%20vbInformation%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3388639%22%20slang%3D%22en-US%22%3ERe%3A%20is%20there%20a%20way%20to%20make%20sure%20my%20macro%20doesn't%20duplicate%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3388639%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1389955%22%20target%3D%22_blank%22%3E%40Suzanne25811%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20correctly%20tweaked%20the%20following%20line...%3C%2FP%3E%3CP%3EwsSource.Range(%22A2%3AAS%22%20%26amp%3B%20FinalRow).SpecialCells(xlCellTypeVisible).Copy%20wsDest.Range(%22A2%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESince%20you%20tweak%20another%20line%20as%20below...%3C%2FP%3E%3CP%3E.AutoFilter%20field%3A%3D%3CFONT%20color%3D%22%23DF0000%22%3E%3CSTRONG%3E46%3C%2FSTRONG%3E%3C%2FFONT%3E%2C%20Criteria1%3A%3Dsh%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAre%20you%20sure%20that%20column%20AT%20contains%20the%20Territories%3F%2046%20in%20the%20above%20line%20of%20code%20means%20column%20AT.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3388910%22%20slang%3D%22en-US%22%3ERe%3A%20is%20there%20a%20way%20to%20make%20sure%20my%20macro%20doesn't%20duplicate%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3388910%22%20slang%3D%22en-US%22%3Eohhhh%2C%20got%20it!!%20I%20just%20needed%20to%20update%20the%20range%20but%20leave%20the%20filter%20alone.%20that%20worked!%20not%20sure%20what%20I%20was%20thinking%20when%20I%20changed%20the%2029%20to%2046.....%20thanks%20again%20for%20your%20help!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3390493%22%20slang%3D%22en-US%22%3ERe%3A%20is%20there%20a%20way%20to%20make%20sure%20my%20macro%20doesn't%20duplicate%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3390493%22%20slang%3D%22en-US%22%3EYou're%20welcome!%3C%2FLINGO-BODY%3E
Occasional Contributor

I posted in another blog and haven't received a response so I am not sure that what I am asking can be done.   I used code from the following article https://docs.microsoft.com/en-us/office/vba/api/excel.range.copy to partially accomplish my goal but I have a few more questions.

I have a file where I dump data every month and then extrapolate data on other tabs. Within that file, I have a "master" sheet where I do the data dump and I was able to copy the macro from the article above and amend it to send data based on data in a specific column (TERR) to a variety of sheets. What I need to accomplish is this - I would like to continue adding to the same sheets each month but if I run the macro, it will keep adding all of the same data every time (in other words, I don't want it to add the previously added data every time I add new data to the master sheet and then run the macro). Is there a way to add to the macro so that it does not add duplicate rows? I could use a combination of two other columns (Item and Invoice) to look at whether or not the data is duplicate. Also, there are columns of data that have formulas in them and when I paste the data to my other sheets, I would like to paste special values instead of the formula. The goal is that I can then sort and filter the data on the other sheets in a variety of ways and give that information to other people. Thanks for your help!!!

 

Public Sub CopyRows()
    Sheets("MORSE Item Sales Analysis").Select
    FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
    For x = 2 To FinalRow
        ThisValue = Cells(x, 29).Value
        If ThisValue = "FORN" Then
            Cells(x, 1).Resize(1, 48).Copy
            Sheets("FORN").Select
            NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
            Cells(NextRow, 1).Select
            ActiveSheet.Paste
            Sheets("MORSE Item Sales Analysis").Select
        ElseIf ThisValue = "GRLK" Then
            Cells(x, 1).Resize(1, 48).Copy
            Sheets("GRLK").Select
            NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
            Cells(NextRow, 1).Select
            ActiveSheet.Paste
            Sheets("MORSE Item Sales Analysis").Select
        ElseIf ThisValue = "NEST" Then
            Cells(x, 1).Resize(1, 48).Copy
            Sheets("NEST").Select
            NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
            Cells(NextRow, 1).Select
            ActiveSheet.Paste
            Sheets("MORSE Item Sales Analysis").Select
        ElseIf ThisValue = "NWST" Then
            Cells(x, 1).Resize(1, 48).Copy
            Sheets("NWST").Select
            NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
            Cells(NextRow, 1).Select
            ActiveSheet.Paste
            Sheets("MORSE Item Sales Analysis").Select
        ElseIf ThisValue = "PLNS" Then
            Cells(x, 1).Resize(1, 48).Copy
            Sheets("PLNS").Select
            NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
            Cells(NextRow, 1).Select
            ActiveSheet.Paste
            Sheets("MORSE Item Sales Analysis").Select
        ElseIf ThisValue = "NEST" Then
            Cells(x, 1).Resize(1, 48).Copy
            Sheets("NEST").Select
            NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
            Cells(NextRow, 1).Select
            ActiveSheet.Paste
            Sheets("MORSE Item Sales Analysis").Select
        ElseIf ThisValue = "NWST" Then
            Cells(x, 1).Resize(1, 48).Copy
            Sheets("NWST").Select
            NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
            Cells(NextRow, 1).Select
            ActiveSheet.Paste
            Sheets("MORSE Item Sales Analysis").Select
        End If
    Next x
End Sub

 

 

9 Replies

@Suzanne25811 

 

Please give this a try and see if this works for you...

 

Sub CopyRows()
    Dim wsSource    As Worksheet
    Dim wsDest      As Worksheet
    Dim shArr       As Variant
    Dim sh          As Variant
    Dim FinalRow    As Long
    Dim NextRow     As Long
    
    Application.ScreenUpdating = False
    
    Set wsSource = ThisWorkbook.Worksheets("MORSE Item Sales Analysis")
    wsSource.AutoFilterMode = False
    FinalRow = wsSource.Cells(Rows.Count, 1).End(xlUp).Row
    
    shArr = Array("FORN", "GRLK", "NEST", "NWST", "PLNS")
    
    With wsSource.Range("A1").CurrentRegion
        For Each sh In shArr
            .AutoFilter field:=29, Criteria1:=sh
            If .Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count > 1 Then
                Set wsDest = ThisWorkbook.Worksheets(sh)
                wsDest.Range("A1").CurrentRegion.Offset(1).ClearContents
                wsSource.Range("A2:AB" & FinalRow).SpecialCells(xlCellTypeVisible).Copy wsDest.Range("A2")
            End If
        Next sh
    End With
    wsSource.AutoFilterMode = False    
    Application.ScreenUpdating = True    
    MsgBox "Task Completed!", vbInformation
End Sub

@Subodh_Tiwari_sktneer thank you for your help.  Do I insert this after all of the code I showed in my message or do I need to insert this for each section I reference in the code?  Once I know what to do with it, I will follow up to let you know how it works.

 

I appreciate you! 

best response confirmed by Suzanne25811 (Occasional Contributor)
Solution

@Suzanne25811 

 

Just replace your existing code with the proposed code and see if that works for you.

It worked in my test file!!! Thank you SO much!!!
You're welcome! Glad it worked as desired.

@Subodh_Tiwari_sktneer 

Good morning!

Yesterday, I added a couple more territories.  Adding the territories worked, I ran the macro and it added the info to the appropriate tabs.   Then I noticed that I was missing columns at the end - when I originally started this there were 29 columns and we have added more so the sheet is now 45 columns wide.  

 

This morning I updated the macro to reflect 45 columns.  I tried re-running the macro but it did not add the "missing" info.  I deleted the information off the tabs, saved the file, and re-ran the macro again but nothing at all transferred to my other sheets FORN, GRLK, NEST, etc.  Can you help?

 

Sub CopyRows()
Dim wsSource As Worksheet
Dim wsDest As Worksheet
Dim shArr As Variant
Dim sh As Variant
Dim FinalRow As Long
Dim NextRow As Long

Application.ScreenUpdating = False

Set wsSource = ThisWorkbook.Worksheets("MORSE Item Sales Analysis")
wsSource.AutoFilterMode = False
FinalRow = wsSource.Cells(Rows.Count, 1).End(xlUp).Row

shArr = Array("FORN", "GRLK", "NEST", "NWST", "PLNS", "SEST", "SWST", "WCAN", "ECAN")

With wsSource.Range("A1").CurrentRegion
For Each sh In shArr
.AutoFilter field:=46, Criteria1:=sh
If .Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count > 1 Then
Set wsDest = ThisWorkbook.Worksheets(sh)
wsDest.Range("A1").CurrentRegion.Offset(1).ClearContents
wsSource.Range("A2:AS" & FinalRow).SpecialCells(xlCellTypeVisible).Copy wsDest.Range("A2")
End If
Next sh
End With
wsSource.AutoFilterMode = False
Application.ScreenUpdating = True
MsgBox "Task Completed!", vbInformation
End Sub

 

@Suzanne25811 

You correctly tweaked the following line...

wsSource.Range("A2:AS" & FinalRow).SpecialCells(xlCellTypeVisible).Copy wsDest.Range("A2")

 

Since you tweak another line as below...

.AutoFilter field:=46, Criteria1:=sh

 

Are you sure that column AT contains the Territories? 46 in the above line of code means column AT.

 

ohhhh, got it!! I just needed to update the range but leave the filter alone. that worked! not sure what I was thinking when I changed the 29 to 46..... thanks again for your help!