Pat_The_Bat
Board Regular
- Joined
- Jul 12, 2018
- Messages
- 83
I have some code working right now where there are 2 master lists of documents that may be needed in a file. The user goes through and puts an "x" next to the documents they want.
The code is doing what it is supposed to,... it copies any document with an x next to it, and moves it to the output page, but then when you run the macro again, it starts adding the same documents to the list.
Once a documents was swept in a previous run, it should no longer get added to the list.
The user may hit the command button to run the sub multiple/many times, so it can't keep adding duplicates every time.
This is what I'm running now:
'Then add any documents from Master to the Doc Checklist
With Sheets("Master").Range("B2:B100").SpecialCells(xlConstants)
.Offset(, 1).Copy Sheets("Doc Checklist").Range("C2")
End With
On Error Resume Next
Sheets("Doc Checklist").Range("C2:C100").SpecialCells(xlBlanks).EntireRow.Delete
On Error GoTo 0
'Then this section looks for any other documents on the Doc Request sheet and adds them to the the Doc Checklist
With Sheets("Doc Request").Range("B17:B100").SpecialCells(xlConstants)
.Offset(, -1).Copy Sheets("Doc Checklist").Range("C2").End(xlDown)
'The line above this needs to reference range = the next available cell in the column C
End With
On Error Resume Next
Sheets("Doc Checklist").Range("C2:C100").SpecialCells(xlBlanks).EntireRow.Delete
On Error GoTo 0
The code is doing what it is supposed to,... it copies any document with an x next to it, and moves it to the output page, but then when you run the macro again, it starts adding the same documents to the list.
Once a documents was swept in a previous run, it should no longer get added to the list.
The user may hit the command button to run the sub multiple/many times, so it can't keep adding duplicates every time.
This is what I'm running now:
'Then add any documents from Master to the Doc Checklist
With Sheets("Master").Range("B2:B100").SpecialCells(xlConstants)
.Offset(, 1).Copy Sheets("Doc Checklist").Range("C2")
End With
On Error Resume Next
Sheets("Doc Checklist").Range("C2:C100").SpecialCells(xlBlanks).EntireRow.Delete
On Error GoTo 0
'Then this section looks for any other documents on the Doc Request sheet and adds them to the the Doc Checklist
With Sheets("Doc Request").Range("B17:B100").SpecialCells(xlConstants)
.Offset(, -1).Copy Sheets("Doc Checklist").Range("C2").End(xlDown)
'The line above this needs to reference range = the next available cell in the column C
End With
On Error Resume Next
Sheets("Doc Checklist").Range("C2:C100").SpecialCells(xlBlanks).EntireRow.Delete
On Error GoTo 0