2016-03-11 22 views
0

这是我的问题:如果某列的值等于“星期六”或“星期天”,我想粗体显示电子表格的整行。我找到了加粗单元格的方法,但不是整行。有人可以帮忙吗? 哦,我还想根据相同的条件将字体从10增加到12。 谢谢!在excel中根据列值加粗一行

+0

'Selection.Font.Bold = True'和'Selection.Font.Size = 12'将帮助你。既然你还没有粘贴你的代码,我不知道你会把它放在哪里,如果你粘贴你的代码,我可以帮助更多 –

+1

值实际上是某人输入的值*星期六*或者它是格式化的日期* dddd * ? – Jeeped

+0

这是键入的东西,而不是日期格式化dddd – RobD64

回答

0

所以...我有点厌烦,使这个为你

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 

简要explincation,该LastRow获得在A列最后一行(只有这样,我们不走以往任何我们需要的数据和intoblank细胞(更改到永远列你需要的列字母))

循环For cRow = 1 To LastRow(乌鸦会+1每个Next cRow)会倒计时细胞,直到它reachs的LastRow

If Cells(cRow, 1) = "Saturday" Or Cells(cRow, 1) = "Sunday" Then将检查电池,如果它在细胞中的值就会然后将其更改为粗体和大小12字体

如果您有什么不清楚的代码让我知道,我将尽力澄清

+0

Mr.Burns,谢谢,这正是我所需要的 – RobD64

+0

没问题,接受这个作为anwser通过点击左侧的答案来显示问题已被回答 –

0
Private TurnRowToBold() 
lLastRow = Cells(Rows.Count, 1).End(xlUp).Row 
For i = 1 To lLastRow 
    If (Worksheets("MySheet").Cells(i, 1) = "Saturday" or Worksheets("MySheet").Cells(i, 1) = "Sunday") Then 
     Worksheets("MySheet").Rows(i).Font.Bold = True 
     Worksheets("MySheet").Rows(i).Font.Size = 12 
    End If 
Next 
End Sub