作者:乔山办公网日期:
返回目录:excel表格制作
定义数组
在字符串中查找ASCII码的范围,分析数字,提取存入数组,然后再找最大最小
0-9 的ASCII码 在48-57
写宏代码,写自定义函数或过程
日期百也度是数知值道的版
Sub 按钮权1_Click()
[e1] = WorksheetFunction.Max(Columns(1))
[e2] = WorksheetFunction.Min(Columns(1))
End Sub
假设有10列,行e79fa5e98193e58685e5aeb9366数不超过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)<activecell.offset(i,j-1) then
maxmin(j,1)=activecell.offset(i,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
MAX函数是计算出一个数组里面的zhidao最大值。
- MAX函数的用法:MAX(参数),参数可以是数字或者是包含数字的名称、数组或引用;
- 例如:计算版B2到B7单元格里面最大的数值,可以在B8单元格里面输入公式=MAX($B$2:$B$7),之后就会显示出最大值了。权