见附件。Sub 按钮e68a84e8a2ade799bee5baa6336" />
乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > <em>excelvba</em>改变<em>字体</em>颜色的问题-

<em>excelvba</em>改变<em>字体</em>颜色的问题-

作者:乔山办公网日期:

返回目录:excel表格制作


请问下您所说的数据标签是指图表中的数据标签吗?

见附件。

Sub 按钮e68a84e8a2ade799bee5baa63361_Click()
For i = 3 To 18 Step 5
    If Cells(i + 1, 8) <> "" Then
        Range(Cells(i, 3), Cells(i + 4, 8)).Font.ColorIndex = 5
    End If
    If Cells(i + 1, 15) <> "" Then
        Range(Cells(i, 10), Cells(i + 4, 15)).Font.ColorIndex = 5
    End If
Next
End Sub
Sub 按钮2_Click()
For i = 3 To 18 Step 5
    If Cells(i + 1, 8) <> "" Then
        Range(Cells(i, 3), Cells(i + 4, 8)).Font.ColorIndex = 1
    End If
    If Cells(i + 1, 15) <> "" Then
        Range(Cells(i, 10), Cells(i + 4, 15)).Font.ColorIndex = 1
    End If
Next
End Sub



Range(Cells(1, 1)

前面加工作表名

sheet1.Range(Cells(1, 1)
sheet2.Range(Cells(1, 1)
sheet?.Range(Cells(1, 1)

字体不加粗,将.Font.Bold=True里的True改为False(有两处)
将F列改为其他 列,请将所有引号里的"F"改为你要的列号字母就行 (有10处)

以下是为636f70797a64337你修改后的代码,请将第2行的"F"改为你要的列号

Sub Test()
Const L ="F" '以后如要改到其他列,只要改这个地方

Dim rng As Range, rngC As Range
Dim intRow As Long
Dim cntRow As Long
Dim cnt As Long
Dim n As Long
Dim dat()
Dim strA As String

Application.ScreenUpdating = False
strA = Empty
intRow = Range("A65536").End(xlUp).Row
Set rng = Range("A2:A" & intRow)
cntRow = rng.Rows.Count
strA = "*" & InputBox("输入要搜索的内容") & "*"
Debug.Print strA
If strA = "**" Then Exit Sub
cnt = Application.WorksheetFunction.CountIf(rng, strA)
ReDim dat(1 To cnt, 1 To 1)
n = 1
For Each rngC In rng
If Application.WorksheetFunction.CountIf(rngC, strA) = 1 Then
dat(n, 1) = rngC
n = n + 1
End If
Next rngC
With Range(L & "1:" & L & Range(L & "65536").End(xlUp).Row)
.ClearContents
.ClearFormats
End With
Range(L & "1") = "搜索结果"
With Range(L & "1")
.Interior.ColorIndex = 20
.Font.Name = "宋体" '这里是字体
.Font.Size = 12 '这里是字体大小
.Font.Bold = False '标题行是否加粗
.Borders.LineStyle = xlContinuous
.HorizontalAlignment = xlCenter
End With
With Range(L & "2:" & L & n)
.Value = dat
.Font.Name = "宋体" '这里是字体
.Font.Size = 12 '这里是字体大小
.Borders.LineStyle = xlContinuous
.Font.Bold = False '搜索结果是否加粗
.Interior.ColorIndex = 19
.HorizontalAlignment = xlCenter
End With

Range(L & "2:" & L & n).Sort key1:=Range(L & "2"), order1:=xlAscending
MsgBox (" 共 " & n - 1 & " 件被搜索.")
Application.ScreenUpdating = True
End Sub

相关阅读

  • <em>excel</em> <em>vba</em> 如何<em

  • 乔山办公网excel表格制作
  • excel中用VBA生成固定的随机数?请高手写出代码" src="/uploads/tu/262.jpg" style="width: 400px; height: 267px;" />i= rndrnd 是 0 到 1之间的数你想随机 0 到 10 的数 就rnd* 10 配合round或者int
关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网