{"id":3636,"date":"2021-10-03T11:22:10","date_gmt":"2021-10-03T18:22:10","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=3636"},"modified":"2021-10-03T11:22:13","modified_gmt":"2021-10-03T18:22:13","slug":"excel-vba-how-to-delete-entire-row-if-contains-certain-text","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=3636","title":{"rendered":"Excel VBA, How to Delete Entire Row if Contains Certain Text"},"content":{"rendered":"\n<p><strong>Question<\/strong><\/p>\n\n\n\n<p>I&#8217;ve searched on here, but every code I put in gives me an error back. Data in column D, If any of the cells contain &#8220;Record Only&#8221; I need it to delete the entire row.<\/p>\n\n\n\n<p><strong>Solution<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Sub DeleteRowWithContents()\n'========================================================================\n' DELETES ALL ROWS FROM A2 DOWNWARDS WITH THE WORDs \"Record Only\" IN COLUMN D\n'========================================================================\n    Last = Cells(Rows.Count, \"D\").End(xlUp).Row\n    For i = Last To 1 Step -1\n        If (Cells(i, \"D\").Value) = \"Record Only\" Then\n    'Cells(i, \"A\").EntireRow.ClearContents ' USE THIS TO CLEAR CONTENTS BUT NOT DELETE ROW\n            Cells(i, \"A\").EntireRow.Delete\n        End If\n    Next i\nEnd Sub<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Question I&#8217;ve searched on here, but every code I put in gives me an error back. Data in column D, If any of the cells contain &#8220;Record Only&#8221; I need it to delete the entire row. Solution<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[10,18],"tags":[891,893,892],"class_list":["post-3636","post","type-post","status-publish","format-standard","hentry","category-microsoft","category-microsoft-office","tag-delete-entire-row-if-contains-certain-text","tag-delete-entire-row-if-contains-certain-text-excel","tag-delete-entire-row-if-contains-certain-text-vba"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3636"}],"version-history":[{"count":1,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3636\/revisions"}],"predecessor-version":[{"id":3637,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3636\/revisions\/3637"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}