2013-10-03 67 views
0

我有這個公式,如果該行中某單元格中包含的任何文本增加了一個邊境行:條件格式如果行中的任意單元格中包含文本

=$C5<>"" 

我想改變公式不只是看看列C,但是在表格的整行(即A:I)中,即如果該行中存在任何文本,則必須應用格式。

看起來似乎沒有正確。

回答

0

只要使用這個公式

=COUNTA($A5:$I5)>0

COUNTA計數非空白單元格所以如果在這個範圍內COUNTA任何文本將是> 0且觸發條件格式

0

試試這個。我測試過它,它適用於我。您需要將表格名稱更改爲「Sheet1」名稱。目前,宏設定爲行100檢查值i = 1到100

Sub FormatCells() 
Dim Wks As Worksheet: Set Wks = Sheets("Sheet1") 
Dim i As Integer 
For i = 1 To 100 ' set the max no of Rows 
LookupRange = Wks.Rows(i) 
    If Application.WorksheetFunction.CountA(Wks.Rows(i)) <> 0 Then 
     With Wks.Rows(i).Borders(xlDiagonalDown).LineStyle = xlNone 
      Wks.Rows(i).Borders(xlDiagonalUp).LineStyle = xlNone 
     End With 
     With Wks.Rows(i).Borders(xlEdgeLeft) 
      .LineStyle = xlContinuous 
      .Weight = xlMedium 
     End With 
     With Wks.Rows(i).Borders(xlEdgeTop) 
      .LineStyle = xlContinuous 
      .Weight = xlMedium 
     End With 
     With Wks.Rows(i).Borders(xlEdgeBottom) 
      .LineStyle = xlContinuous 
      .Weight = xlMedium 
     End With 
     With Wks.Rows(i).Borders(xlEdgeRight) 
      .LineStyle = xlContinuous 
      .Weight = xlMedium 
     End With 
    End If 
Next i 
End Sub 

希望這有助於。乾杯!

+0

有什麼辦法這樣做沒有宏?這是我自己和新手excel用戶之間每天共享的文件。寧願保持簡單的事情。宏雖然工作得很好。 – user2725402

+0

我看不到沒有宏時這將如何完成。 作爲一種解決方法,我會:1.)**使宏私人**(即私人子...)2.)**在一個單獨的工作表中添加一個對象**(又名。按鈕)(如果需要隱藏)並**將宏分配給它**。 3)。 **只需點擊一下鼠標即可運行宏,而不會干擾數據? – Takedasama

+0

@ user2725402 - 你應該可以通過對現有公式的簡單修改來實現此目的 - 請參閱我的回答 –

相關問題