do loop help

R

rbekka33

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)+1>ROWS(BlanksRange)-COUNTBLANK(BlanksRange),"""",INDIRECT(ADDRESS(SMALL((IF(BlanksRange<>"""",ROW(BlanksRange),ROW()+ROWS(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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top