假设有10列,行数不超过100行的数据。从第三行开始是你的数据,最后在第一行写最大值,第二行写最小值。
dim maxmin(10,2) as single
dim i as integer
dim j as integer
range("A2").select
for i=1 to 10
for j =1 to 2
maxmin(i,j)=0
next j,i
for i=1 to 100
if activecell.offset(i,0)="" then '第一列出现空行即结束
goto wri
endif
for j=1 to 10
if maxmin(j,1)=0 then
maxmin(j,1)=activecell.offset(i,j-1)
elseif maxmin(j,1)
endif
if maxmin(j,2)=0 then
maxmin(j,2)=activecell.offset(i,j-1)
elseif maxmin(j,2)>activecell.offset(i,j-1) then
maxmin(j,2)=activecell.offset(i,j-1)
endif
next j
next i
wri:
for j=1 to 10
activecell.offset(-1,j-1)=maxmin(j,1)
activecell.offset(0,j-1)=maxmin(j,2)
next j