The prefix of the underscore is for another part of the whole project however, it works well for the next part where I show the VBA. Look for text 'Gross Pay' Need to delete Blank Rows From 'Gross pay ' up. Table Tools > Design > Properties > Table Name Excel table = ListObjectsĪLWAYS name your Excel tables. I needed to write VBA to fix the blank rows that may exist since it is likely the user will not always remember to ‘Delete Table Row’ when clearing the value from DeptID. In the new way, it became possible that blank rows may occur since I gave freedom to the user’s in the form of an Excel table. Each ‘Delete Depts’ chose the row to be removed. Each ‘Add Depts’ controlled where the additional DeptID would be placed. The old way did not need to handle empty rows. Simple data collection using an Excel Table Old vs. The user just needs to type ‘Enter’ after each DeptID. When the user understands how an Excel table works, the duration of the process is greatly decreased. For each entry, you have to click ‘Add Depts’ then click ‘OK’ Collecting DeptID criteria – the new way My motivation to improve this process was simply could I do it better. Everyone got used to clicking the buttons just fine. So I needed a way to “auto-magically” remove the rows that did not meet my requirements a type of data validation if you will.
How to delete certain rows in excel vba how to#
I think they are awesome! Unfortunately, not everyone knows how to use them.
How to delete certain rows in excel vba code#
An example of the flexibility in the VBA code used to meet the goal The GoalĬreate a dynamic method to collect DeptID’s that are eventually used as filter criteria.
Sub DeleteBlankRowsForLoop () Dim ws As Worksheet Set ws ThisWorkbook.Sheets ('Sheet1') Dim lrow As Long lrow ws.UsedRange.Rows. Code to delete above highlighted blank rows is as follows. If there a no non-blank cells in a row, the function will return a zero, which means that the row is blank. I will focus on one small part of the entire project in this post as I ended up revamping the entire file. We could use the Excel CountA function in VBA. I was excited to have the opportunity to potentially improve the file that was originally created in 2002.
I was invited to collaborate on an Excel file that is used by all of the Student Attendance Clerks at our campus. In this post, I am going to show you how to delete Excel table rows based on criteria using VBA.