• 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.

Need to delete specific cells in a row [SOLVED]

brightyoyo

New Member
Hi


I have a Macro that lets me delete an entire row based on the beginning letter of a specified cell. However, I just need to delete two specific cells in that row not the entire row.


Code:
Dim LR As Long


[code]Application.ScreenUpdating = False


    [code]For LR = Range("D" & Rows.Count).End(xlUp).Row To 2 Step -1

[code]If Range("D" & LR).Value = "" Or Left(Range("D" & LR), 1) = "M" Then

Rows(LR).EntireRow.Delete

End If[/code]

Next LR[/code]


Application.ScreenUpdating = True[/code]


I just need the cells in column D and E To be deleted.


Thank You
 
Hi, brightyoyo!


I was wondering what were you be doing, it's not that I missed you... :)


That macro sounds familiar to me, don't know why...


You now say you don't want to delete the whole row but only cells in range D:E, are you referring to erasing its contents or to actually removing the cells from the worksheet? If it's this last case, what should be done, shifting remaining cells of row to the left or remaining cells of the column upwards?


Regards!
 
Hi, brightyoyo!


Change this:

-----

Code:
Rows(LR).EntireRow.Delete

-----

to this:

-----

Range("D" & LR & ":" & "E" & LR).Delete Shift:=xlUp

-----


Regards!
 
Hi SirJB7


Thanks that worked perfectly, as usual. The macro I found at MrExcel and changed for my purposes. Maybe that is why it is familiar.


Once again thank You for the speedy help.
 
Hi, brightyoyo!

It's familiar because I fixed it for you at an earlier topic, I guess. Maybe here:

http://chandoo.org/forums/topic/delete-rows

Glad you solved it. Thanks for your feedback and welcome back whenever needed or wanted.

Regards!
 
Hi SirJB7


In that topic I wanted to filter a specified column and then output the filtered results into separate workbooks. Where as here I was filtering and deleting cells based on there 1st Letter.


And Yes you help me solve that one as well.


Thanks
 
Hi, brightyoyo!

It doesn't matter at all, but if you want to check it... the title topic says "Delete rows", and in your 1st post you say "Im am looking for a way to delete a row that has a cell that begins with certain letters".

Regards!
 
Back
Top