看看这个 sub macro2() with [a1].resize([a65536].end(xlup).row, 1) .formular1c1 = "=if(countif(r1c3:rc3,rc3)=1,1,1/0) " '重點 .specialcells(xlcelltypeformulas, 16).entirerow.select 'delete end with end sub
发表于:2007-02-14 17:53:164楼 得分:0
sub macro1() ' dim arrrow() as string dim num as long
num = 0 redim arrrow(num)
for i = 1 to activecell.specialcells(xlcelltypelastcell).row '记录凡是颜色=灰色的行号 if rows(i).interior.colorindex = 16 then arrrow(num) = i num = num + 1 redim preserve arrrow(num) end if '记录重复的行号 for j = 1 to i - 1 if cells(i, 1) = cells(j, 1) then arrrow(num) = i num = num + 1 redim preserve arrrow(num) exit for end if next next
'通过行号,组成一个选择范围 strtemp = " " for i = 0 to ubound(arrrow) - 1 ' debug.print arrrow(i) if strtemp <> " " then strtemp = strtemp + ", " + arrrow(i) + ": " + arrrow(i) else strtemp = strtemp + arrrow(i) + ": " + arrrow(i) end if next '选择组成的行范围 range(strtemp).select '删除选择的行 selection.delete shift:=xlup