TopLearner
Board Regular
- Joined
- Feb 25, 2022
- Messages
- 57
- Office Version
- 365
- Platform
- Windows
Hello everybody,
I hope you are well.
I have the column A with multiple cities.
A1 is the header "Location"
Then, I have the name of cities in the range A1:A200.
I also have the column B with the header "Revenue"
I would like to create a macro that delete those rows that contains "(Central)" in the "Location" column, column "A"
My attempt is
However, it is not working as cells in column A contain either cities' names like Milan or cities' names + (Central). For instance Cordoba (Central).
Then, I would like to delete the row that contains Cordoba (Central)
Would it be something like the below?
Thanks
Sanchez
I hope you are well.
I have the column A with multiple cities.
A1 is the header "Location"
Then, I have the name of cities in the range A1:A200.
I also have the column B with the header "Revenue"
I would like to create a macro that delete those rows that contains "(Central)" in the "Location" column, column "A"
My attempt is
VBA Code:
Sub LimpiarFilas()
Dim ws As Worksheet
Dim cell As Range
Set ws = Sheet1
For Each cell In Range("A:A")
If cell.Value = "(Central)" Then
cell.EntireRow.Delete
End If
Next cell
End Sub
However, it is not working as cells in column A contain either cities' names like Milan or cities' names + (Central). For instance Cordoba (Central).
Then, I would like to delete the row that contains Cordoba (Central)
Would it be something like the below?
VBA Code:
IF cell.value = IF(Isnumber(match("(Central)",B1)),"Yes","No").Value = "Yes" Then
cell.entirerow.delete
Thanks
Sanchez