Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Ashan Kaya   on Oct 27 In MS Office Category.

  
Question Answered By: Russell Burns   on Oct 27

I never use a Do While or Do Until anymore. To much chance for
infinite loops. I use For Next. For example if you know the rows  are
5 to 15, in a delete  run a backwards For Next. As for the merged
cells, maybe removing xlup will work. Or unmerging them and
remerging them. Anyway heres a for next loop:

Range("A5:C15").Select
Selection.Sort Key1:=Range("A5"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Dim i as integer, Val1 as string

For i = 15 to 5 step -1
Val1 = Range("D"& i).value
if Val1 = 0 then
range("D"& i).EntireColumn.Delete 'shift:=xlUp
end if
next i

Share: 

 
 
Didn't find what you were looking for? Find more on merged fields Or get search suggestion and latest updates.


Tagged: