Office Excel宏有关问题
Office Excel宏问题求救
在Office Excel中
如: A B A B
1 学号 姓名 1 学号 学分
2 01 a 2 01 1
3 02 b 3 02 2
4 03 c 4 03 3
5 04 d 5 04 4
6 09 5
sheet1 sheet2
在这2个sheet中 选择出以sheet1为标准的a栏学号的数值与sheet2中的a栏相同的数值,然后对相同的项目用相同的颜色标记出来.
老师布置的课题为在excel中编写宏得出结果.只为我们分析了一点..我现在把理解下来的部分代码写出.请大家帮我参考..修改修改.谢谢了.
Sub Macro1()
Dim i, j As Integer
For i = 2 To 5
For j = 2 To 6
Next
Next
If Sheet1.Cells(i, 2) = Sheet2.Cells(j, 2) Then
Sheet1.Cells.Font.Color = "111111"
Sheet2.Cells.Font.Color = "111111"
End If
End Sub
------解决方案--------------------
应该是这样
Sub Macro1()
Dim i, j As Integer
For i = 2 To 5
For j = 2 To 6
If Sheet1.Cells(i, 2).Value = Sheet2.Cells(j, 2).Value Then
Sheets("Sheet1").Select
Cells(i, 2).Font.ColorIndex = 3 '
Sheets("Sheet2").Select
Cells(j, 2).Font.ColorIndex = 3
End If
Next
Next
End Sub
在Office Excel中
如: A B A B
1 学号 姓名 1 学号 学分
2 01 a 2 01 1
3 02 b 3 02 2
4 03 c 4 03 3
5 04 d 5 04 4
6 09 5
sheet1 sheet2
在这2个sheet中 选择出以sheet1为标准的a栏学号的数值与sheet2中的a栏相同的数值,然后对相同的项目用相同的颜色标记出来.
老师布置的课题为在excel中编写宏得出结果.只为我们分析了一点..我现在把理解下来的部分代码写出.请大家帮我参考..修改修改.谢谢了.
Sub Macro1()
Dim i, j As Integer
For i = 2 To 5
For j = 2 To 6
Next
Next
If Sheet1.Cells(i, 2) = Sheet2.Cells(j, 2) Then
Sheet1.Cells.Font.Color = "111111"
Sheet2.Cells.Font.Color = "111111"
End If
End Sub
------解决方案--------------------
应该是这样
Sub Macro1()
Dim i, j As Integer
For i = 2 To 5
For j = 2 To 6
If Sheet1.Cells(i, 2).Value = Sheet2.Cells(j, 2).Value Then
Sheets("Sheet1").Select
Cells(i, 2).Font.ColorIndex = 3 '
Sheets("Sheet2").Select
Cells(j, 2).Font.ColorIndex = 3
End If
Next
Next
End Sub