excel - What is the bug with these VBA code? -
My task is to delete the whole line if the column has zero value. The first thing is the looping in my mind, but I can have 4000 rows and 1000 rows of Kashmir values as zero.
sub DeleteRowWithContents () final = cells (rows.Count, 'D'). End (xlUp) .Row i = The last step is -1 -1 (Cells (I, "K"). Value) = 0 Then cells (I, "A"). EntireRow.Delete end then next I end up I believe people say that it is taking time because it is looping. This is the reason why I thought better for the next methods and people told me that 'Find' is faster than looping, so I found the code given below when I
sub Delete_zeros () Dimmer RCell as the Range dim strAddress string. Application.ScreenUpdating = false with ThisWorkbook.Sheets (1) .Activate was used to googling ActiveSheet.Columns ("K") set rCell = .find (What: = 0, looking: = xlValues, SearchOrder: = xlByColumns) no rCell is nothing then then strAddress = rCell.Address rCell.EntireRow.Delete set rCell Do = then FindNext (strAddress) is nothing until the loop rCell is end, so end with the application.ScreenUpdating = True End Sub but I found the above code, also if the line The removal is that 10 or 20 values in K column. I mean, if the number is zero, then delete it
example
204 or 200 or 205 or 301 or 10; delete all these rows < / Pre> Is these codes wrong? This code is faster than looping, I wanted to use but I got a bug with it.
Please explain the cause of the bug and any other help in the second method which is fast to remove the rows, if it is zero value in the column other than looping (maybe even looping Should be fast)? It will be greatly appreciated. Thanks
No bugs, find the method for this parameter
LookAt: = xlwhole
Use the filter to
sub filterAndDelete (http://officevb.com) a staining sht 'worksheet as a developer from Bruno Late' Range as a Blur FilterRange - Set your Sheet Set = This Workbook Sheets ("Plan 2") Verify that if filter is done, then Sht.FilterMode is a Sht.ShowAllData one end if one filter with a filter column A (A A: A) with 0. Autofilter field: = 1, criterion1: = "0" Define range of cells visible without a line title Set FilterRange = Sht.Range ("A1"). CurrentRegion.Offset (1, 0). Specialcale (xlCellTypeVisible) an application DisplayAlerts = False FilterRange.Rows.Delete an application. Performance alerts = true is a true Sht.ShowAllData one last sub
Comments
Post a Comment