根据列值在excel中加粗一行
这是我的问题:如果其中一列的值等于“Saturday”或“Sunday”,我想将电子表格的整行加粗。我找到了加粗单元格的方法,但不是整行。有人能帮忙吗? 哦,我还想根据同样的条件把字体从10增加到12。根据列值在excel中加粗一行,excel,text,format,conditional-statements,Excel,Text,Format,Conditional Statements,这是我的问题:如果其中一列的值等于“Saturday”或“Sunday”,我想将电子表格的整行加粗。我找到了加粗单元格的方法,但不是整行。有人能帮忙吗? 哦,我还想根据同样的条件把字体从10增加到12。 谢谢 所以。。。我有点无聊,给你做了这个 Sub Test() Dim cRow as Long Dim rRow As Range Dim LastRow As Long 'Gets the last row with data in it LastRow = [A65000].End(x
谢谢 所以。。。我有点无聊,给你做了这个
Sub Test()
Dim cRow as Long
Dim rRow As Range
Dim LastRow As Long
'Gets the last row with data in it
LastRow = [A65000].End(xlUp).Row
'the look to move down the cells
For cRow = 1 To LastRow
'if statment so catch the values that are wanted
If Cells(cRow, 1) = "Saturday" Or Cells(cRow, 1) = "Sunday" Then
'the changes made to the rows
Rows(cRow).Font.Bold = True
Rows(cRow).Font.Size = 12
End If
Next cRow
End Sub
简要说明,LastRow
获取A列中的最后一行(这是必需的,这样我们就不会越过需要的任何数据进入空白单元格(将您需要的列字母更改为哪一列))
cRow=1到最后一行的循环(cRow将为每个下一次cRow
加1)将对单元格进行倒计时,直到到达最后一行
如果单元格(cRow,1)=“Saturday”或单元格(cRow,1)=“Sunday”,则将检查单元格,如果单元格中有值,则将其更改为粗体,大小为12字体
如果代码中有任何您不清楚的地方,请告诉我,我将尝试澄清Selection.Font.Bold=True
,然后Selection.Font.Size=12
将为您提供帮助。既然你还没有粘贴你的代码,我不知道你会把它放在哪里,如果你粘贴你的代码,我可以帮你更多的忙。它的值实际上是某人键入的星期六的值,还是已经格式化的日期?它是键入的,而不是格式化的日期。伯恩斯先生,谢谢,这正是我所需要的没有问题,通过单击答案左侧的勾号,将此作为答案接受,以显示问题已被回答
Sub Test()
Dim cRow as Long
Dim rRow As Range
Dim LastRow As Long
'Gets the last row with data in it
LastRow = [A65000].End(xlUp).Row
'the look to move down the cells
For cRow = 1 To LastRow
'if statment so catch the values that are wanted
If Cells(cRow, 1) = "Saturday" Or Cells(cRow, 1) = "Sunday" Then
'the changes made to the rows
Rows(cRow).Font.Bold = True
Rows(cRow).Font.Size = 12
End If
Next cRow
End Sub