How to prevent duplicate in VBA Excel

Mickie01

New Member
Joined
May 15, 2018
Messages
2
Dear Team,

I wants to post my monthly sales data in total sales sheet for every month by VBA (macros sheet), I am very new to using VBA, could u please help me to give steps by steps, so when we are posting current month sales in total sales sheet it will prevent us to create of duplication. Because we are a team who working on sales data and if one of my colleague mistakely run macros which i already processed for the month it will create duplicates values.


Thank you in advance,
Regards.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Welcome to the Board!

This seems to be a very popular question today, as there have been a few other similar questions to this posted today.

This question is very difficult to answer without seeing what your data looks like.

Questions include:
- How many columns are your data?
- What constitutes a duplicate (do all columns need to match, or just certain ones)?
- How exactly is the data being copied? If by VBA code, please post your code.

Perhaps you could have some sort of flag that the macro updates at the end
(i.e. populate an unused cell in Excel), to let it know what was the last month that it ran against. Then, you could use that in your code to make sure it doesn't process that same data again.
 
Upvote 0
Hi,

Answers,
- I have 7 columns data
- i wants just one column to be prevent from duplication "A", its contains date which i want that if macros run and it will search same date in data file it should stop running.
- Code, In bold i used for msgbox for duplication but its not stopped macro.

Sub Apend_Data()'
' Apend_Data Macro
'


'
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Copy
Workbooks.Open Filename:= _
"C:\Users\hdaman\Documents\VBA Alghanim\VBA\Orders.xlsx"
Range("A1").Select
Selection.End(xlDown).Select
'Range("A3267").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


MsgBox "You Are not Allowed to page the Same Date Twice in the same Month"



ActiveWindow.Close savechanges:=True
Application.CutCopyMode = False
Range("A1").Select
End Sub



Regards.

Welcome to the Board!

This seems to be a very popular question today, as there have been a few other similar questions to this posted today.

This question is very difficult to answer without seeing what your data looks like.

Questions include:
- How many columns are your data?
- What constitutes a duplicate (do all columns need to match, or just certain ones)?
- How exactly is the data being copied? If by VBA code, please post your code.

Perhaps you could have some sort of flag that the macro updates at the end
(i.e. populate an unused cell in Excel), to let it know what was the last month that it ran against. Then, you could use that in your code to make sure it doesn't process that same data again.
 
Upvote 0
Will you just be copying over one row at a time, or are there multiple rows?
 
Upvote 0
I would say so. All four threads are coming from the same city, and one of the other threads is even using the same file path as the one used in the code in this post.

Mickie01,
Note that while people may be willing to give you some "hints", please do not expect people to do your homework assignments for you.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top