求一段excel vba循环代码
我想把下面的代码效果应用到工作簿我选中的每个单元格,应该怎么添加代码?单元格里都是八个字母的。WithActiveCell.Characters(Start:=1,Len...
我想把下面的代码效果应用到工作簿我选中的每个单元格,应该怎么添加代码? 单元格里都是八个字母的。 With ActiveCell.Characters(Start:=1, Length:=0).Font .Name = "Consolas" .FontStyle = "常规" .Size = 10 End With With ActiveCell.Characters(Start:=1, Length:=1).Font .Name = "Consolas" .FontStyle = "常规" .Size = 9 End With With ActiveCell.Characters(Start:=2, Length:=1).Font .Name = "Consolas" .FontStyle = "常规" .Size = 10 End With With ActiveCell.Characters(Start:=3, Length:=1).Font .Name = "Consolas" .FontStyle = "常规" .Size = 11 End With With ActiveCell.Characters(Start:=4, Length:=1).Font .Name = "Consolas" .FontStyle = "常规" .Size = 12 End With With ActiveCell.Characters(Start:=5, Length:=1).Font .Name = "Consolas" .FontStyle = "常规" .Size = 13 End With With ActiveCell.Characters(Start:=6, Length:=1).Font .Name = "Consolas" .FontStyle = "常规" .Size = 14 End With With ActiveCell.Characters(Start:=7, Length:=1).Font .Name = "Consolas" .FontStyle = "常规" .Size = 15 End With With ActiveCell.Characters(Start:=8, Length:=1).Font .Name = "Consolas" .FontStyle = "常规" .Size = 16 End With 上边的代码是用excel录制的,不太懂vba,顺便帮忙看看有没有问题。
展开
1个回答
展开全部
Sub
FontFormat()
Dim
rngSelect
As
Range
Set
rngSelect
=
Worksheets("Sheet1").Range("A1:G10")
For
Each
Cell
In
rngSelect
With
Cell.Characters(Start:=8,
Length:=1).Font
.Name
=
"宋体"
.FontStyle
=
"常规"
.Size
=
16
End
With
Next
End
Sub
代码基本上是这样的,可以根据你的需要修改一下。
FontFormat()
Dim
rngSelect
As
Range
Set
rngSelect
=
Worksheets("Sheet1").Range("A1:G10")
For
Each
Cell
In
rngSelect
With
Cell.Characters(Start:=8,
Length:=1).Font
.Name
=
"宋体"
.FontStyle
=
"常规"
.Size
=
16
End
With
Next
End
Sub
代码基本上是这样的,可以根据你的需要修改一下。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询