MENU

Fun & Interesting

How to get the Last Row in VBA(The Right Way!)

Excel Macro Mastery 178,156 3 years ago
Video Not Working? Fix It Now

Learn how to write real-world Excel VBA code: ?https://courses.excelmacromastery.com/ Want to download the source code for this video? Go here: https://bit.ly/3cqvT0o Subscribe to the channel here: https://bit.ly/36hpTCY One of the most common VBA questions is how do I get the Last Row with data. And the most common answer to this question is normally wrong. In this video I'm going to show you the 5 methods for getting the last row and which is the best. I'm also going to give you some simple VBA functions that will do the work for you. All the code used in this video is available to download from the link in the description below. #VBALastRow #ExcelLastRow Useful VBA Shortcut Keys ======================== Debugging: Compile the code: Alt + D + L OR Alt + D + Enter Run the code from the current sub: F5 Step into the code line by line: F8 Add a breakpoint to pause the code: F9(or click left margin) Windows: View the Immediate Window: Ctrl + G View the Watch Window: Alt + V + H View the Properties Window: F4 Switch between Excel and the VBA Editor: Alt + F11 View the Project Explorer Window: Ctrl + R Writing Code: Search keyword under cursor: Ctrl + F3 Search the word last searched for: F3 Auto complete word: Ctrl + Space Get the definition of the item under the cursor: Shift + F2 Go to the last cursor position: Ctrl + Shift + F2 Get the current region on a worksheet: Ctrl + Shift + 8(or Ctrl + *) To move lines of code to the right(Indent): Tab To move lines of code to the left(Outdent): Shift + Tab Delete a Line: Ctrl + Y(note: this clears the clipboard) Table of Contents: 00:00 - Introduction 03:12 - UsedRange 05:28 - Special Cells 08:19 - End (xlUp) 11:27 - Range.Find 13:54 - FindLastRow Functions

Comment