detriez
Board Regular
- Joined
- Sep 13, 2011
- Messages
- 193
- Office Version
- 365
- Platform
- Windows
I've got a named range (nPersonalEmailDomain) with email domains... gmail.com, yahoo.com etc
I need to delete the entire row where an email in Column C is on the nPersonalEmailDomain list
So, If an email in Column C = bob@gmail.com, delete the entire row
This code fails with Compile Error: User-defined type not defined at Dim nRng As Range, rng As Range, c As Cell, n As Cell
I need to delete the entire row where an email in Column C is on the nPersonalEmailDomain list
So, If an email in Column C = bob@gmail.com, delete the entire row
This code fails with Compile Error: User-defined type not defined at Dim nRng As Range, rng As Range, c As Cell, n As Cell
VBA Code:
Sub PersonalEmails(Control As IRibbonControl)
Dim nRng As Range, rng As Range, c As Cell, n As Cell
Set nRng = Range("nPersonalEmailDomain") 'my named range containing the list of personal email domains
Set rng = Range("C2", ActiveSheet.Cells(Rows.Count, "c").End(xlUp)) 'get col C parameters
For Each c In rng 'Look at each item in col C
For Each n In nRng
If InStr(c.Text, n.Text) > 0 Then
c.EntireRow.Delete 'Delete rows with match to named range
Exit For
End If
Next
Next
End Sub