Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
Loop Heather O'Malley Excel Discussion (Misc queries) 1 November 6th 06 02:39 PM
vba loop Jackie Excel Discussion (Misc queries) 4 February 28th 06 04:20 AM
Worksheet_Change - loop within a loop bgm Excel Programming 1 January 19th 04 01:27 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 08:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"