2013-03-31 30 views
0

如何調整此代碼以突出顯示直到最後一列的行,在我的情況下是「J」而不是EntireRow?突出顯示一行,直到最後一列

For Each wb In Workbooks 
    If wb.Name <> "Book1.xlsm" Then 
    wb.Activate 

    For Each ws In ActiveWorkbook.Worksheets 
     Set cl = ws.Cells.Find(What:=SearchString, _ 
     After:=ws.Cells(1, 1), _ 
     LookIn:=xlValues, _ 
     LookAt:=xlWhole, _ 
     SearchOrder:=xlByRows, _ 
     SearchDirection:=xlNext, _ 
     MatchCase:=False, _ 
     SearchFormat:=False) 
      If Not cl Is Nothing Then 
       FirstFound = cl.Address 
      Do 
        cl.EntireRow.Interior.ColorIndex = Cor 
       Set cl = ws.Cells.FindNext(After:=cl) 
     Loop Until FirstFound = cl.Address 
      End If 
    Next ‘ etc etc 

回答

2

變化
cl.EntireRow.Interior.ColorIndex = Cor
到:
ws.Range("A" & cl.Row & ":J" & cl.row).Interior.ColorIndex = Cor

+0

嗨,@Ross McConegghy,謝謝! –

+1

不客氣,您可以更改'「A」'和'「:J」'開始並結束所需列上的突出顯示。感謝您接受我的回答=) –