{"id":7755,"date":"2017-06-13T05:36:54","date_gmt":"2017-06-13T05:36:54","guid":{"rendered":"http:\/\/www.nurturetechacademy.in\/?p=7755"},"modified":"2017-06-10T15:05:49","modified_gmt":"2017-06-10T15:05:49","slug":"pasting-data-filtered-rows","status":"publish","type":"post","link":"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/pasting-data-filtered-rows\/","title":{"rendered":"Pasting Data on Filtered Rows"},"content":{"rendered":"<p>When we paste data on filtered rows it always past it on both visible and hidden rows. And if you are doing this for a huge set of data then I am sure you must be pasting it manually and wasting lot of time and efforts. Don\u2019t worry guys, we have a solution for this but only through VBA.<\/p>\n<p>So let\u2019s see an example, below is a screenshot of a filtered data:<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-7757 size-full\" src=\"http:\/\/www.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/1-1.png\" alt=\"1\" width=\"721\" height=\"400\" srcset=\"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/1-1.png 721w, https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/1-1-600x333.png 600w, https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/1-1-300x166.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>When you simply use Copy and paste it looks like this:<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-7758 size-full\" src=\"http:\/\/www.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/2-1.png\" alt=\"2\" width=\"416\" height=\"356\" srcset=\"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/2-1.png 416w, https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/2-1-300x257.png 300w\" sizes=\"auto, (max-width: 416px) 100vw, 416px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>So it will get pasted on hidden rows also, to avoid the same, please follow the below steps :<\/p>\n<ol>\n<li>Press Alt + F11 keys simultaneously, and a Microsoft Visual Basic for Applications (VBA) window will open.<\/li>\n<li>Click Insert &gt; Module, then paste below VBA code to the Module window.<\/li>\n<\/ol>\n<p><strong><em>Sub PasteOnVisibleCells()<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0 Dim rg1 As Range<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0 Dim rg2 As Range<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0 Dim CopyRg As Range<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0 Dim PasteRg As Range<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0 Set CopyRg = Application.Selection<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0 Set CopyRg = Application.InputBox(&#8220;Copy Range :&#8221;, , CopyRg.Address, Type:=8)<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0 Set PasteRg = Application.InputBox(&#8220;Paste Range:&#8221;, , Type:=8)<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0 For Each rg1 In CopyRg<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 rg1.Copy<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 For Each rg2 In PasteRg<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 If rg2.EntireRow.RowHeight &gt; 0 Then<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 rg2.PasteSpecial<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Set PasteRg = rg2.Offset(1).Resize(PasteRg.Rows.Count)<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Exit For<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 End If<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Next<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0 Next<\/em><\/strong><\/p>\n<p><strong><em>\u00a0\u00a0\u00a0 Application.CutCopyMode = False<\/em><\/strong><\/p>\n<p><strong><em>End Sub<\/em><\/strong><\/p>\n<ol start=\"3\">\n<li>Click F5 key or the Run button, a dialog box will appear for you to select Range to copy<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-7759 size-full\" src=\"http:\/\/www.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/3-1.png\" alt=\"3\" width=\"398\" height=\"279\" srcset=\"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/3-1.png 398w, https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/3-1-300x210.png 300w\" sizes=\"auto, (max-width: 398px) 100vw, 398px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>4. After selecting the range, click OK, and then another dialog box will appear for you to select a range to paste the copied data in.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-7756 size-full\" src=\"http:\/\/www.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/4.png\" alt=\"4\" width=\"525\" height=\"645\" srcset=\"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/4.png 525w, https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-content\/uploads\/2017\/06\/4-244x300.png 244w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>5. Click OK to get your desired result.<\/p>\n<p>&nbsp;<\/p>\n<p>Download the same file <a href=\"https:\/\/www.dropbox.com\/s\/gnrz9i08js86r8a\/Pasting%20Data%20on%20Filtered%20Rows.xlsm?dl=0\">here<\/a>.<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_7755\" class=\"pvc_stats all  \" data-element-id=\"7755\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>When we paste data on filtered rows it always past it on both visible and hidden rows. And if you are doing this for a huge set of data then I am sure you must be pasting it manually and <\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_7755\" class=\"pvc_stats all  \" data-element-id=\"7755\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":7760,"comment_status":"open","ping_status":"open","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,"footnotes":""},"categories":[56],"tags":[71,57,233,235,234],"class_list":["post-7755","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-excel","tag-advanced-excel","tag-excel","tag-filter","tag-filtered-data","tag-vba"],"_links":{"self":[{"href":"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-json\/wp\/v2\/posts\/7755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-json\/wp\/v2\/comments?post=7755"}],"version-history":[{"count":1,"href":"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-json\/wp\/v2\/posts\/7755\/revisions"}],"predecessor-version":[{"id":7761,"href":"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-json\/wp\/v2\/posts\/7755\/revisions\/7761"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-json\/wp\/v2\/media\/7760"}],"wp:attachment":[{"href":"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-json\/wp\/v2\/media?parent=7755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-json\/wp\/v2\/categories?post=7755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nurturetechacademy.in\/dev.nurturetechacademy.in\/wp-json\/wp\/v2\/tags?post=7755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}