作者:乔山办公网日期:
返回目录:excel表格制作
Sub xx()
n = UsedRange.Item(UsedRange.Count).Row
If n <= 100 Then Exit Sub
For j = Asc("s") To Asc("y")
For i = 100 To n
If Cells(i, Chr(j)).Interior.ColorIndex = 10 Then Cells(9, Chr(j)).Interior.Color = 10: Exit For
Next
Next
End Sub
Public Sub 查找抄颜色百() '用于当度前知工作道表
Dim CXys As Range
For Each CXys In ActiveSheet.UsedRange
If CXys.Interior.ColorIndex <> -4142 And CXys.Row > 100 And CXys.Column >= 56 And CXys.Column <= 71 Then
Cells(9, CXys.Column).Interior.ColorIndex = CXys.Interior.ColorIndex
End If
Next CXys
End Sub
提供一个宏作为参考吧,VBA应该可以实现,不过你得要把代码作一些改e79fa5e98193e58685e5aeb9336造:
如下是把第1单元格的“12345678”中的56变成红色
Sub Macro3()
'
' Macro3 Macro
' 宏由 MC SYSTEM 录制,时间: 2015-8-22
'
Range("A1").Select
ActiveCell.FormulaR1C1 = "1234567890"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=5, Length:=2).Font
.ColorIndex = 3
End With
With ActiveCell.Characters(Start:=7, Length:=4).Font
.ColorIndex = xlAutomatic
End With
Range("E7").Select
End Sub
注:如果单元格内是数字需先设置成文本格式,因为否则VBA更改的格式会被数字格式化
就看不到结果了.
程序知如下道:内
Sub 宏容()
Dim i As Integer, j As Integer, k As Integer
For i = 4 To 41
k = Cells(Rows.Count, i).End(xlUp).Row
Range(Cells(k - 4, i), Cells(k, i)).Select
Selection.Copy
Cells(1, i).Select
ActiveSheet.Paste
Next
End Sub