ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Help: delete whole row if the cell does not contain string "*" (https://www.excelbanter.com/excel-programming/349797-vba-help-delete-whole-row-if-cell-does-not-contain-string-%2A.html)

zenzen

VBA Help: delete whole row if the cell does not contain string "*"
 

Hi all,

I am only a beginner in VBA. I have come across the problem where I
have a range of data in excel. In each rows, I want to check if the
cell in that row does contain a string "*".

If the row where the cell does not contain string "*" I want to delete
the whole row.


I am having problem in figure out how to relate each cell search if it
contains a string"*".

Can anyone give me some idea/help?

Thanks

ZenZen


--
zenzen
------------------------------------------------------------------------
zenzen's Profile: http://www.excelforum.com/member.php...o&userid=30224
View this thread: http://www.excelforum.com/showthread...hreadid=499014


Paul W Smith[_4_]

VBA Help: delete whole row if the cell does not contain string "*"
 
Pseudo-code:

Loop down the column of the cells you are checking, something like...

Do
{Check Deletion criteria}
move one row down
Loop until end criteria

If the deletion criteria matches, move to the next row and then delete the
previous.

Checkcell.offset(-1,0).entirerow.delete

HTH



"zenzen" wrote in
message ...

Hi all,

I am only a beginner in VBA. I have come across the problem where I
have a range of data in excel. In each rows, I want to check if the
cell in that row does contain a string "*".

If the row where the cell does not contain string "*" I want to delete
the whole row.


I am having problem in figure out how to relate each cell search if it
contains a string"*".

Can anyone give me some idea/help?

Thanks

ZenZen


--
zenzen
------------------------------------------------------------------------
zenzen's Profile:
http://www.excelforum.com/member.php...o&userid=30224
View this thread: http://www.excelforum.com/showthread...hreadid=499014




Gary Keramidas

VBA Help: delete whole row if the cell does not contain string "*"
 
when you need to delete a row, it's better to start at the last row and work
your way up.

--


Gary


"zenzen" wrote in
message ...

Hi all,

I am only a beginner in VBA. I have come across the problem where I
have a range of data in excel. In each rows, I want to check if the
cell in that row does contain a string "*".

If the row where the cell does not contain string "*" I want to delete
the whole row.


I am having problem in figure out how to relate each cell search if it
contains a string"*".

Can anyone give me some idea/help?

Thanks

ZenZen


--
zenzen
------------------------------------------------------------------------
zenzen's Profile:
http://www.excelforum.com/member.php...o&userid=30224
View this thread: http://www.excelforum.com/showthread...hreadid=499014




Ron de Bruin

VBA Help: delete whole row if the cell does not contain string "*"
 
I have a few examples here
http://www.rondebruin.nl/delete.htm

You can change the = for < to do what you want

--
Regards Ron de Bruin
http://www.rondebruin.nl


"zenzen" wrote in message
...

Hi all,

I am only a beginner in VBA. I have come across the problem where I
have a range of data in excel. In each rows, I want to check if the
cell in that row does contain a string "*".

If the row where the cell does not contain string "*" I want to delete
the whole row.


I am having problem in figure out how to relate each cell search if it
contains a string"*".

Can anyone give me some idea/help?

Thanks

ZenZen


--
zenzen
------------------------------------------------------------------------
zenzen's Profile: http://www.excelforum.com/member.php...o&userid=30224
View this thread: http://www.excelforum.com/showthread...hreadid=499014




zenzen[_2_]

VBA Help: delete whole row if the cell does not contain string "*"
 

Thank you everyone!

I now have some idea and will try it out


--
zenzen
------------------------------------------------------------------------
zenzen's Profile: http://www.excelforum.com/member.php...o&userid=30224
View this thread: http://www.excelforum.com/showthread...hreadid=499014



All times are GMT +1. The time now is 07:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com