Thanks, I moved the formula in an empty cell and also added -1 after ROWS(V$24:V25) in If statement as shown below and now it works just fine. I am using 2010 version.
=IF(ROWS(V$24:V25)-1>U$24,"",SMALL((D$22:H$22,D$29:H$29,D$36:H$36,D$43:H$43),FREQUENCY((D$22:H$22,D$29:H$29,D$36:H$36,D$43:H$43),V24)+1))
there is no way I could have thought of this solution, so thanks again