Deleting rows

azizrasul

Well-known Member
Joined
Jul 7, 2003
Messages
1,304
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I want to delete rows based values other than specific values. Here's the code I am using which gives me an error on the .Delete line.

Code:
Set ws = ThisWorkbook.Sheets("tblComputerSystemInformation")

With ws.Range("C2:C" & WorksheetFunction.CountA(Range("tblComputerSystemInformation[nametype]")))
        .AutoFilter Field:=4, Criteria1:="Not In ('OSArchitecture','Name','OSLanguage')"
        .SpecialCells(xlCellTypeVisible).Delete
End With

In MS Access you can use criteria like

Code:
Not In ('OSArchitecture','Name','OSLanguage')

Is it possible to do something similar in MS Excel?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hey there,

Create a copy of your workbook (it's always good to do this, VBA can make irreversible damage to a xl file and data) and give this code bellow a try.

.EntireRow.Delete
Instead of
.Delete

VBA Code:
Set ws = ThisWorkbook.Sheets("tblComputerSystemInformation")


With ws.Range("C2:C" & WorksheetFunction.CountA(Range("tblComputerSystemInformation[nametype]")))

        .AutoFilter Field:=4, Criteria1:="Not In ('OSArchitecture','Name','OSLanguage')"

        .SpecialCells(xlCellTypeVisible).EntireRow.Delete

End With
 
Upvote 0
Hey there,

Create a copy of your workbook (it's always good to do this, VBA can make irreversible damage to a xl file and data) and give this code bellow a try.

.EntireRow.Delete
Instead of
.Delete

VBA Code:
Set ws = ThisWorkbook.Sheets("tblComputerSystemInformation")


With ws.Range("C2:C" & WorksheetFunction.CountA(Range("tblComputerSystemInformation[nametype]")))

        .AutoFilter Field:=4, Criteria1:="Not In ('OSArchitecture','Name','OSLanguage')"

        .SpecialCells(xlCellTypeVisible).EntireRow.Delete

End With
 
Upvote 0
I get the error 'No cells were found' on the .EntireRow.Delete line.
 
Upvote 0
Oh I see,
That is a macro to filter values right?
Can you provide the file so we can take a look?
 
Upvote 0
Using a online upload service like dropbox or something like that I belive.
 
Upvote 0
Using a online upload service like dropbox or something like that I belive.
Do you want to give me your email address so that I can add it to my dropbox and you can then download the file.
 
Upvote 0
You mark the file for sharing in your dropbox and then post the link it provides in the thread.
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,276
Members
449,075
Latest member
staticfluids

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