Outputįinding Last Used Row with Data: Example Fileĭownload the example file and see the example case of finding last used row with data. In second for loop we are finding the maximum value and changing the font to bold after this loopĬells(iMaxRow, iCntr + 1).Font.Bold = True Instructions:ĭownload the file below and lick on the FindMax button and Explore the Code. The second For loop is to loop through the rows (Rows are not fixed), the number of rows we found in step:2ĥ. The first For loop is to loop through the fixed number of Columns (5), i.e RegionsĤ. Range(Cells(2, 2), Cells(lRow, 6)).Font.Bold = Falseįor jCntr = 2 To lRow ' for each row from 2nd rowģ. Find maxim sales from 5 Regions and Bold the Font.Number of Departments could be any thing between 1 to 25 (In this data it is 5 but it is not fixed- it will vary).User wants to paste his data for 5 Regions.The following example will show you real time example and when need find the last Row with data. Now Run a Macro, you should see a message box as shown belowįinding Last Used Row with Data – Case Study.
So, your last used row is 10 and Row with Data is 8. To check, enter some data in a worksheet (suppose at D10) and delete and enter some data before this Row (suppose at G8).
Excel vba on worksheet change get row code#
Copy the above code and Paste in the code window.LRow = (xlLastCell).Rowĭo While Application.CountA(ActiveSheet.Rows(lRow)) = 0 And lRow 1 'In this example we are finding the last Row of an ActiveSheet
Excel vba on worksheet change get row how to#
The following example will show you how to find last row with data.