Delete rows after moving to another tab

luthersonus

New Member
Joined
May 4, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have several codes that I've pieced together (I'm a beginner). I have 2 tabs. One with a table named Append1 and the other tab is named "Drop". In the Append1 table, I indicate if a student has dropped by putting in "Drop" in Column 1 (the table begins at A6). I then need all the dropped students to be moved to the Drop Tab, duplicates removed and deleted from the Append1 table. I want it to do all this every time I open the workbook once data has been refreshed.

What I have put together works, except that for one thing. It deletes the Drops from the Append1 table after moving to the drop tab, however after it deletes them, it adds them back to the Append1 table. Any advice would be appreciated!

Thank you


Sub Workbook_RefreshAll()
ActiveWorkbook.RefreshAll
MsgBox "Data has been refreshed!"

Dim wsUse As Worksheet
Dim wsDc As Worksheet
Dim strdc As String
Application.ScreenUpdating = False
Application.Calculation = xlCalculationAutomatic

Call HighlightDrops
End Sub


Sub HighlightDrops()
HighlightDrops Macro
Range("Append1[Drop]").Select
Call MoveDrops
End Sub


Sub MoveDrops()
For Each myCell In Selection.Columns(1).Cells
If myCell.Value = "Drop" Then
myCell.EntireRow.Copy Worksheets("Drops").Range("A" & Rows.Count).End(3)(2)
myCell.EntireRow.Delete
End If
Next
Call RemoveDups

End Sub

Sub RemoveDups()
RemoveDups Macro
Sheets("Drops").Select
Range("A1").Select
ActiveSheet.Range("$A$1:$AA$500").RemoveDuplicates Columns:=2, Header:=xlYes
Sheets("WABERS.Tuition Sum 22").Select
Range("Append1[[#Headers],[Drop]]").Select

End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Update- It looks like the issue seems to be with the code refreshing. If I remove the call to Highlight Drops, then it works just fine.

Sub Workbook_RefreshAll()
ActiveWorkbook.RefreshAll
MsgBox "Data has been refreshed!"

Dim wsUse As Worksheet
Dim wsDc As Worksheet
Dim strdc As String
Application.ScreenUpdating = False
Application.Calculation = xlCalculationAutomatic

Call HighlightDrops
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,983
Messages
6,122,592
Members
449,089
Latest member
Motoracer88

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