Looking for a macro that will delete an entire line if row value found on a separate tab.
Example attached, thanks so much in advance.
Looking for a macro that will delete an entire line if row value found on a separate tab.
Example attached, thanks so much in advance.
Try this code
PHP Code:
Option Explicit
Sub deleteR()
Dim user As Range, cell As Range, U As Range
With Sheets("range")
Set user = .Range("A1:A" & .Cells(Rows.Count, "A").End(xlUp).Row)
End With
Sheets("listing").Activate
For Each cell In Range("B2:B" & Cells(Rows.Count, "B").End(xlUp).Row)
If WorksheetFunction.CountIf(user, cell) Then
If U Is Nothing Then
Set U = cell
Else
Set U = Union(U, cell)
End If
End If
Next
If Not U Is Nothing Then U.EntireRow.Delete
[A1].Select
End Sub
Quang PT
Good preparation for a simple AdvancedFilter.
![]()
Please Login or Register to view this content.
An alternative with Power Query
Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").![]()
Please Login or Register to view this content.
It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.
- Follow this link to learn how to install Power Query in Excel 2010 / 2013.
- Follow this link for an introduction to Power Query functionality.
- Follow this link for a video which demonstrates how to use Power Query code provided.
Alan עַם יִשְׂרָאֵל חַי
Change an Ugly Report with Power Query
Database Normalization
Complete Guide to Power Query
Man's Mind Stretched to New Dimensions Never Returns to Its Original Form
![]()
Please Login or Register to view this content.
Good Luck...
I don't presume to know what I am doing, however, just like you, I too started somewhere...
One-day, One-problem at a time!!!
If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
Also....Add a comment if you like!!!!
And remember...Mark Thread as Solved...
Excel Forum Rocks!!!
Again....
Only for the reason to reduce the code lines without adding proper error trap is the worst of all.
Understood...Am offering for supplied sample file based on availability of said values...Results are correct...
Check your result...Is deleting "support1" too...
![]()
Please Login or Register to view this content.
Noted...As per jindon...best is to incorporate if no matches found...without adding proper error trap is the worst of all
![]()
Please Login or Register to view this content.
Not enough.
Your code is based on the assumption of no blank cells in co.B.
And what is the need of "IF(ROW)" close in formula?
Last edited by jindon; 05-04-2024 at 09:37 AM.
jindon, thanks so very much!!!!
code works perfectly.
You are welcome and thanks for the feedback.
And thanks for the PM.
another ways
![]()
Please Login or Register to view this content.
Last edited by daboho; 05-04-2024 at 11:37 AM.
![]()
"Presh Star Who has help you *For Add Reputation!! And mark case as Solve"
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks