Thread: do loop help
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
rbekka33[_11_] rbekka33[_11_] is offline
external usenet poster
 
Posts: 1
Default do loop help

Hi there,

I am trying to find unique codes and then removes the blank
efficiently but i am not sure how to use a loop properly. In fact -
don't really know how to write code as I am trying to teach myself - a
assistance will be appreciated.

Down the bottom I want to stop the autofill when the cells in column
have no formulas.


Sub ExtractUniqueEngCodes()
Application.ScreenUpdating = False
ActiveCell.FormulaR1C1
"=IF(COUNTIF(R5C1:R5000C1,RC[-2])=0,RC[-2],"""")"
Selection.AutoFill Destination:=Range("G5:G7000")
Type:=xlFillDefault
'this range could be dynamic if i knew how

ActiveWorkbook.Names.Add Name:="BlanksRange", RefersTo:= _
"=OFFSET(Sheet1!$g$5,0,0,COUNTA(Sheet1!$A:$A), 1)"
Visible:=True
ActiveWorkbook.Names.Add Name:="NoBlanksRange", RefersTo:= _
"=OFFSET(Sheet1!$h$5,0,0,COUNTA(Sheet1!$e:$e), 1)"
Visible:=True
Range("H5").Select

Selection.FormulaArray = _

"=IF(ROW()-ROW(NoBlanksRange)+1ROWS(BlanksRange)-COUNTBLANK(BlanksRange),"""",INDIRECT(ADDRESS(SMAL L((IF(BlanksRange<"""",ROW(BlanksRange),ROW()+ROW S(BlanksRange))),ROW()-ROW(NoBlanksRange)+1),COLUMN(BlanksRange),4)))"

' Do loop
Selection.AutoFill Destination:=Range("h5:h1000")
Type:=xlFillDefault
'this range could be dynamic if i knew how
' until

Application.ScreenUpdating = True

end sub

thanks in anticipatio

--
Message posted from http://www.ExcelForum.com