VBA整型变量问题
来源:百度知道 编辑:UC知道 时间:2024/05/27 04:03:20
dim i as integer,j as integer,s,n as integer
for i=1 to 4'行
s=0
for j=1 to 4'列
if cells(i,j)>s then s=cells(i,j):n=j
next j
Cells(i, n).Interior.Color = RGB(255, 255, 0)
next i
高手你还在吗 你有QQ吗 能和你聊一下吗?
不用那么麻烦~如果你只是想比较单元格显示的内容的大小的话只要用cells(i,j).text来代替cells(i,j).value就可以了~cells的默认属性是value,所以cells(i,j)表示的是cells(i,j).value~所以你的代码可以改成:
dim i as integer,j as integer,s,n as integer
for i=1 to 4'行
s=0
for j=1 to 4'列
if cells(i,j).text>s then s=cells(i,j).text:n=j
next j
Cells(i, n).Interior.Color = RGB(255, 255, 0)
next i
问题补充:高手你还在吗 你有QQ吗 能和你聊一下吗?
把判断那行"if..."的前半部分,里边改成:
if int(100*cells(ij))>int(100*s)
后半行一样,我手里没装环境,如果不对请在问题补充里告诉我。
dim i as integer,j as integer,s,n as integer
for i=1 to 4'行
s=0
for j=1 to 4'列
if round(cells(i,j),2)>s then s=round(cells(i,j),2):n=j
next j
Cells(i, n).Interior.Color = RGB(255, 255, 0)
next i
子易空间站 - Excel培训专家
不好意思,昨天晚上有事没来得及给你写,刚写了一下,测试过没有问题,你看一下:
'代码开始================================
Sub Temp()
Dim iRow, iColumn, iMax, iiMaxColumn, m, n, i, j As In