excel里如何进行匹配替换

来源:百度知道 编辑:UC知道 时间:2024/06/02 00:34:53
第一列的表格数为
2
6
0
4
8
.....都是0 2 6 8这些偶数
0对应的数是:05
2对应的数是:16
4对应的数是:27
6对应的数是:38
8对应的数是:49
我想再另外一列输出
16
38
05
27
49
.....
如何替换? 急!!!
============================
还有假如A B C 三格 分别是1 2 3 三个数 在E格的一个数和A B C进行匹配,假如是123 其中的一个就是变成棕色,不是的 颜色将不变化!
如何进行!

宏,会用吗?代码如下:
(1)
假设第一列为:2、6、0、4、8
在第二列输出对应的数,数据表名为sheet1
sub abc()
for i=1 to 5'从第一行到第五行
if sheet1.cells(i,1)=0 then sheet1.cells(i,2)="05"
if sheet1.cells(i,1)=2 then sheet1.cells(i,2)=16
if sheet1.cells(i,1)=4 then sheet1.cells(i,2)=27
if sheet1.cells(i,1)=6 then sheet1.cells(i,2)=38
if sheet1.cells(i,1)=8 then sheet1.cells(i,2)=49
next i
end sub
F5运行就OK
(2)
sub a()
for i=1 to 3'第一列到第三列
if sheet1.cells(1,5)=sheet1.cells(1,i) then sheet1.cells(1,5).Font.ColorIndex = 9
next i
end sub
F5运行。
其中ColorIndex = 5是一种颜色,ColorIndex一共有56种颜色从你可以用一下语句看一下这十五种颜色,来决定用哪一种(这是将第三列的单元格的背景利用ColorIndex = i填充上一中颜色)
Sub b()
For i = 1 To 56
Sheet1.Cells(i, 3).Interior.ColorIndex = i
Sheet1.Cells(i, 3).Interior.Pattern = xlSolid
Sheet1.Cells(i, 3).Interior.PatternColorIndex = xlAutomatic
Next i
End Sub

在另外一列输出,怎么叫替换呢?你的数