• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Delete Rows

brightyoyo

New Member
Hi Im am looking for a way to delete a row that has a cell that begins with certain letters. I have searched the site and internet and could not find something that could meet my specific criteria.


Example:

[pre]
Code:
CR21	  2939.85	  2997.98	90	Top
CR25	  3226.85	  3130.46	270	Top
E1	     3964	     3039	0	Top
E2	     3764	     3039	0	Top
E4	     3384	     3039	0	Top
L8	  1875.32	   112.68	90	Top
L9	  2391.74	       70	90	Top
MTH1	      620	     3124	0	Top
MTH14	   2820.5	     1687	0	Top
MTH15	     5412	     1687	0	Top
P1	     5794	      703	90	Top
Q2	     2395	     2970	270	Top
[/pre]
I am looking to get rid of any row that starts with M and E, but depending on my data that list could grow.


Thank You
 
Hi, brighyoyo!

http://chandoo.org/wp/search/?q=delete%20a%20row%20upon%20column%20condition

Regards!
 
Hi SirJB7

I check the search and must of the results were regarding deleting blank cells. The few others are deleting cells with whole words. I just what to delete the row based on the first letter in the first cell.


Thank You for your time
 
Hi, brightyoyo!


In the first example of the link, this:

http://chandoo.org/forums/topic/macro-needed-to-remove-rows-based-on-predefined-condition

(incidentally which I wrote), you have to change only this line:

-----

Code:
.Cells(I, iTestColumn).Value = sTestValue Then

-----

for a new line that instead of testing the entire value of the cell against a witness (variable sTestValue) it performs a test of the first character in cell against an "M" or that first character against an "E".


If you'd been able to incorporate all the other previous code into your projects I think you'd have no issue managing to handle this modification. I almost wrote the code in the previous paragraph. Give it a try.


Regards!


PS: After that you could get rid of anything related to the sTestValue variable (dimension, assigning values, ranges related), but it'd work too if you don't.
 
Hi SirJB7

I was able to get the macro working, but not able to get it to delete the row based on the first letter in the cell. Any help would be appreciated.


Thank You
 
Hi, brightyoyo!

Would you upload your workbook with the macro incorporated and the changes you've made?

Regards!
 
Hi, brightyoyo!


Give a look at this file:

https://dl.dropboxusercontent.com/u/60558749/Delete%20Rows%20-%20deleting_trial%20%28for%20brightyoyo%20at%20chandoo.org%29.xlsm


Check parameters worksheets.


Regards!
 
Hi, brightyoyo!


Glad you solved it, and it isn't that I were reluctant to provide you a solution, there were just intents to make you get your hands dirty into the code, it's the first step for learning. And you'd be able to handle slight modifications to the code you use.


Thanks for your feedback and for your kind words too. And welcome back whenever needed or wanted.


Regards!
 
Back
Top