excel - VBA code delete the row of noisy data -


sub project()     dim a, deltat_value1, deltat_value2, deltat_value3 integer     = 2             deltat_value1 = cells(a, 7).value         deltat_value2 = cells(a + 1, 7).value         deltat_value3 = cells(a + 2, 7).value         if abs(deltat_value1 - deltat_value2) > 5 , abs(deltat_value2 - deltat_value3) > 5         rows(a + 1).entirerow.delete         end if         = + 1     loop until deltat_value1 = 14700 end sub 

i trying delete noisy data, set if data point has difference bigger 5 both points above , below it, noisy data , set delete whole row of noisy data. however, having problem line:

deltat_value3=cells(a+2,7).value runtime error 1004 "application-defined or object-defined error" 

and running takes extremely longer time. new user of vba programming , think method may inefficient, there may other ways work better, advice?

how about:

sub ytrewq()     dim long, deltat_value1 long, deltat_value2 long, deltat_value3 long     dim rkill range      = 2             deltat_value1 = cells(a, 7).value         deltat_value2 = cells(a + 1, 7).value         deltat_value3 = cells(a + 2, 7).value         if abs(deltat_value1 - deltat_value2) > 5 , abs(deltat_value2 - deltat_value3) > 5             if rkill nothing                set rkill = cells(a + 1, 1)             else                set rkill = union(rkill, cells(a + 1, 1))             end if         end if         = + 1     loop until deltat_value1 = 14700      rkill.entirerow.delete end sub 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -