{"id":14613,"date":"2021-12-15T11:53:38","date_gmt":"2021-12-15T11:53:38","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=14613"},"modified":"2021-12-15T11:53:57","modified_gmt":"2021-12-15T11:53:57","slug":"inserting-row-into-another-sheet-vba","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/office\/inserting-row-into-another-sheet-vba\/16401.html","title":{"rendered":"Inserting Row Into Another Sheet VBA"},"content":{"rendered":"<p>I am trying to insert a row that meets a cell criteria into another sheet. When it copies over to the second sheet, it just replaces the first row instead of shifting the cells. Here is my code below. I have the &#8220;Selection.Insert Shift:=xlDown&#8221; line of code which I thought would shift the cells down before inserting, but it&#8217;s not working.<\/p>\n<p>Private Sub Worksheet_SelectionChange(ByVal Target As Range)<\/p>\n<p>&#8216; The code below copies any row with column &#8220;B&#8221; containing the &#8220;Completed&#8221;<br \/>\n&#8216; to the &#8220;Completed Tasks&#8221; sheet.<\/p>\n<p>Set t = Sheets(&#8220;Tasks&#8221;)<br \/>\nSet c = Sheets(&#8220;Completed Tasks&#8221;)<br \/>\nDim d<br \/>\nDim j<br \/>\nd = 1<br \/>\nj = 2<\/p>\n<p>Do Until IsEmpty(t.Range(&#8220;B&#8221; &amp; j))<\/p>\n<p>If t.Range(&#8220;B&#8221; &amp; j) = &#8220;Completed&#8221; Then<br \/>\nd = d + 1<br \/>\nc.Rows(d).Value = t.Rows(j).Value<br \/>\nSelection.Insert Shift:=xlDown<\/p>\n<p>End If<br \/>\nj = j + 1<br \/>\nLoop<\/p>\n<p>End Sub<\/p>\n<p>Any ideas??<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":5},"question-category":[53],"question_tags":[],"class_list":["post-14613","question","type-question","status-publish","hentry","question-category-office"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/14613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=14613"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=14613"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=14613"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=14613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}