{"id":3987,"date":"2019-01-14T12:45:04","date_gmt":"2019-01-14T12:45:04","guid":{"rendered":"http:\/\/officetuts.net\/excel\/?p=3987"},"modified":"2024-03-30T00:19:17","modified_gmt":"2024-03-30T00:19:17","slug":"find-last-row","status":"publish","type":"post","link":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/","title":{"rendered":"VBA Find Last Row"},"content":{"rendered":"\n

Here, I\u2019m going to show you a few ways to get the last row using the VBA code.<\/p>\n\n\n\n

Find the last row in the current column<\/h2>\n\n\n\n

This is the example we are going to use.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

Click any cell inside column A (A1:A6) and run this code.<\/p>\n\n\n\n

Sub LastRow()\n    MsgBox Selection.End(xlDown).Row\nEnd Sub<\/pre>\n\n\n\n

You can also set a cell, instead of using the active cell.<\/p>\n\n\n\n

Sub LastRow()\n    MsgBox Range(\"A1\").End(xlDown).Row\nEnd Sub<\/pre>\n\n\n\n

Both Subs will return the same result in this case.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

Find the last row in the current column (with blanks)<\/h2>\n\n\n\n

The Subs I presented to you will work until there is no blank cell on the way. If there is at least one, it will return incorrect results.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

Let\u2019s modify our Sub a bit, to deal with this problem.<\/p>\n\n\n\n

Sub LastRowWithBlanks()\n    row_number = Range(\"A1048576\").End(xlUp).Row\n    MsgBox row_number\nEnd Sub<\/pre>\n\n\n\n

Code explanation<\/strong><\/p>\n\n\n\n

Now, instead of moving the cursor down from the first cell, we move the cursor to the last row and then move up. When it meets cells that are not empty, it gets the row number and displays it in the MsgBox<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"

Here, I\u2019m going to show you a few ways to get the last row using the VBA code. Find the last row in…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[190],"yoast_head":"\nVBA Find Last Row<\/title>\n<meta name=\"description\" content=\"Learn how to find the last row using VBA code in Excel. Includes examples for locating the last row in the current column or a specific cell.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"VBA Find Last Row\" \/>\n<meta property=\"og:description\" content=\"Learn how to find the last row using VBA code in Excel. Includes examples for locating the last row in the current column or a specific cell.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-01-14T12:45:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-30T00:19:17+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2019\/01\/last-row-example.png\" \/>\n<meta name=\"author\" content=\"Tomasz Decker\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tomasz Decker\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/\"},\"author\":{\"name\":\"Tomasz Decker\",\"@id\":\"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42\"},\"headline\":\"VBA Find Last Row\",\"datePublished\":\"2019-01-14T12:45:04+00:00\",\"dateModified\":\"2024-03-30T00:19:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/\"},\"wordCount\":168,\"publisher\":{\"@id\":\"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42\"},\"image\":{\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2019\/01\/last-row-example.png\",\"keywords\":[\"pinterest\"],\"articleSection\":[\"vba\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/\",\"url\":\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/\",\"name\":\"VBA Find Last Row\",\"isPartOf\":{\"@id\":\"https:\/\/officetuts.net\/excel\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2019\/01\/last-row-example.png\",\"datePublished\":\"2019-01-14T12:45:04+00:00\",\"dateModified\":\"2024-03-30T00:19:17+00:00\",\"description\":\"Learn how to find the last row using VBA code in Excel. Includes examples for locating the last row in the current column or a specific cell.\",\"breadcrumb\":{\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#primaryimage\",\"url\":\"http:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2019\/01\/last-row-example.png\",\"contentUrl\":\"http:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2019\/01\/last-row-example.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/officetuts.net\/excel\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"VBA Find Last Row\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/officetuts.net\/excel\/#website\",\"url\":\"https:\/\/officetuts.net\/excel\/\",\"name\":\"\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/officetuts.net\/excel\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42\",\"name\":\"Tomasz Decker\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/officetuts.net\/excel\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/18cbe22837193574870ae40ba56bf712?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/18cbe22837193574870ae40ba56bf712?s=96&d=mm&r=g\",\"caption\":\"Tomasz Decker\"},\"logo\":{\"@id\":\"https:\/\/officetuts.net\/excel\/#\/schema\/person\/image\/\"},\"description\":\"Spreadsheet and Python enthusiast.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"VBA Find Last Row","description":"Learn how to find the last row using VBA code in Excel. Includes examples for locating the last row in the current column or a specific cell.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/","og_locale":"en_US","og_type":"article","og_title":"VBA Find Last Row","og_description":"Learn how to find the last row using VBA code in Excel. Includes examples for locating the last row in the current column or a specific cell.","og_url":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/","article_published_time":"2019-01-14T12:45:04+00:00","article_modified_time":"2024-03-30T00:19:17+00:00","og_image":[{"url":"http:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2019\/01\/last-row-example.png"}],"author":"Tomasz Decker","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Tomasz Decker","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#article","isPartOf":{"@id":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/"},"author":{"name":"Tomasz Decker","@id":"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42"},"headline":"VBA Find Last Row","datePublished":"2019-01-14T12:45:04+00:00","dateModified":"2024-03-30T00:19:17+00:00","mainEntityOfPage":{"@id":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/"},"wordCount":168,"publisher":{"@id":"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42"},"image":{"@id":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#primaryimage"},"thumbnailUrl":"http:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2019\/01\/last-row-example.png","keywords":["pinterest"],"articleSection":["vba"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/","url":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/","name":"VBA Find Last Row","isPartOf":{"@id":"https:\/\/officetuts.net\/excel\/#website"},"primaryImageOfPage":{"@id":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#primaryimage"},"image":{"@id":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#primaryimage"},"thumbnailUrl":"http:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2019\/01\/last-row-example.png","datePublished":"2019-01-14T12:45:04+00:00","dateModified":"2024-03-30T00:19:17+00:00","description":"Learn how to find the last row using VBA code in Excel. Includes examples for locating the last row in the current column or a specific cell.","breadcrumb":{"@id":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/officetuts.net\/excel\/vba\/find-last-row\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#primaryimage","url":"http:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2019\/01\/last-row-example.png","contentUrl":"http:\/\/officetuts.net\/excel\/wp-content\/uploads\/sites\/2\/2019\/01\/last-row-example.png"},{"@type":"BreadcrumbList","@id":"https:\/\/officetuts.net\/excel\/vba\/find-last-row\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/officetuts.net\/excel\/"},{"@type":"ListItem","position":2,"name":"VBA Find Last Row"}]},{"@type":"WebSite","@id":"https:\/\/officetuts.net\/excel\/#website","url":"https:\/\/officetuts.net\/excel\/","name":"","description":"","publisher":{"@id":"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/officetuts.net\/excel\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/officetuts.net\/excel\/#\/schema\/person\/41b0b6996aaa4c4127f86f3d24452d42","name":"Tomasz Decker","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/officetuts.net\/excel\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/18cbe22837193574870ae40ba56bf712?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/18cbe22837193574870ae40ba56bf712?s=96&d=mm&r=g","caption":"Tomasz Decker"},"logo":{"@id":"https:\/\/officetuts.net\/excel\/#\/schema\/person\/image\/"},"description":"Spreadsheet and Python enthusiast."}]}},"_links":{"self":[{"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/posts\/3987"}],"collection":[{"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/comments?post=3987"}],"version-history":[{"count":3,"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/posts\/3987\/revisions"}],"predecessor-version":[{"id":12947,"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/posts\/3987\/revisions\/12947"}],"wp:attachment":[{"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/media?parent=3987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/categories?post=3987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/officetuts.net\/excel\/wp-json\/wp\/v2\/tags?post=3987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}