[英]VBA Excel Change Content of another Cell based on content of one cell
[英]Using VBA to change font type based on excel cell content
我正在嘗試使用 VBA 來更改工作表的格式。 我需要做兩件事:
我已經能夠完成下面的 1,但無法弄清楚 2:
Sub FormatText()
Dim xCell As Range
For Each xCell In Sheets("Output").Range("A16:A64")
With xCell
If Len(.Text) > 100 Then
.Font.Name = "Arial Medium"
Else
.Font.Name = "Calibri Bold"
End If
End With
Next
End Sub
您可以將該條件添加到您的 If 語句中:
Sub FormatText()
Dim xCell As Range
For Each xCell In Sheets("Output").Range("A16:A64")
With xCell
If Len(.Text) > 100 Or Instr(.Text, Chr$(149)) > 0 Then
.Font.Name = "Arial Medium"
Else
.Font.Name = "Calibri Bold"
End If
End With
Next
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.