Once added to the list, Don't add again

Status
Not open for further replies.

Pat_The_Bat

Board Regular
Joined
Jul 12, 2018
Messages
83
I'm using the code below to create a master list from a pick list. User put's "x"'s next to any document on the picklist that they want to show up on the master list on the following sheet.
The code is working, but the problem is that it is also continues to add multiple instances of the same document if you run the macro several times.
The user will definitely go back to run the macro additional times, because it is common that you continue to add to this list as you go. I need to make it so that once item is on the list, it doesn't get added again (unless the user resets/clears the list).
I'm going to create a command button that simply clears all the documents added to the list and resets everything back to the beginning, so that should take care of the reset.
For the issue of documents getting added twice, I'm thinking it's an IF statement. Or possibly as I add documents to the list I could create a second step where the code adds the document to the list AND puts an "x" in a hidden column on the Doc Request Sheet. Then adjust the code to check for SpecialCells(xlConstants) in Column B AND Column C. This way if a doc has already been put on the master list, it will have the "x" in column B that the user entered, and it will have the "x" in column C that the macro put in, and in those cases the macro will not add that document to the list. But in the cases where there is user-entered "x" in column B, and there is NOT an "x" in column C, the document WILL get added to the list.
Wondering if I'm on the right track here, and also struggling with the syntax of how to do what I'm describing above.





Sub LR()


Dim LSTROW As Integer


With Sheets("Doc Request").Range("B2:B100").SpecialCells(xlConstants)
.Offset(, -1).Copy
End With


With Worksheets("Doc Checklist")
LSTROW = .Range("C" & .Rows.Count).End(xlUp).Row + 1

'fill next available cell with a new data
.Range("C" & LSTROW).PasteSpecial xlPasteAll
End With


End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Duplicate https://www.mrexcel.com/forum/excel...duplicates-final-output-list.html#post5113103

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

If you do not receive a response, you can "bump" it by replying to it again, though we advise you to wait 24 hours before doing and not to bump a thread more than once a day.

 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,980
Messages
6,175,766
Members
452,668
Latest member
mrider123

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