Hi All,
I have a requirement to delete a row in a table if few of the columns in the table doesn't contain data using a macro or VB code
can anyone help me on this please.
Thank you,
mahi
Hi All,
I have a requirement to delete a row in a table if few of the columns in the table doesn't contain data using a macro or VB code
can anyone help me on this please.
Thank you,
mahi
Million solutions, better post a workbook explaining your case in more detail
Hey mahi4tech..
why don't you post some sample code. It will be easier to help you with the solution!![]()
Hi ,
I have attached a sample excel with a table named "Table2" with 7 columns
my requirement is i need to delete a row in my table if say column 1,2 and 4 doesnt have any data in their respective cells
req.png
Find attached, should get you started. Not the neatest approach, perhaps somebody has cleaner coded method?
Code:
![]()
Sub DeleteRowsFromTable() Dim tbl As Range Dim r, c, rend As Integer Set tbl = ActiveSheet.ListObjects("Table1").Range rend = tbl.Rows.Count r = 1 Do While r <> rend + 1 continueonsamerow: Debug.Print Cells(r, 3).Address & " value = " & Cells(r, 3).Value & vbTab & Cells(r, 6).Address & " value = " & Cells(r, 6).Value If Cells(r, 3).Value = "" Or Cells(r, 6).Value = "" Then tbl.Range(Cells(r, 1), Cells(r, 9)).Delete rend = rend - 1 GoTo continueonsamerow End If r = r + 1 Loop MsgBox "Done" End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks