2011-06-03 5 views
1

私はC#コーダーです。これまでのところ、これは私が望むものを表現するための最良の方法です。 私はマイクロソフトのExcel 2003ワークシート上でこのコードを実行することを考えています。 これは可能でしょうか?MS Excel 2003のバックグラウンドを変更してください

第一ステップ

if(CellA1 == "Sunday" || CellA1== "Saturday"){ 
    // code to set background color of 
    // CellB1 to CellF1 to background color red 
} 

第二ステップ

// Execute this process from CellA1 until CellA10  
for(CellA1 up to CellA10){ 
    // do first step 
} 

だから私はMSExcel 2003年やってみたかったのコードでは、私はこの

for(int CellCount = 1;CellCount<10;CellCount++){ 

    if("CellA"+CellCount.ToString() == "Sunday" || 
     "CellA"+CellCount.ToString() == "Sunday"){ 

     // set ["CellB"+CellCount.ToString()].CellBackgroundColor="#FF0000"; 
     // set ["CellC"+CellCount.ToString()].CellBackgroundColor="#FF0000"; 
     // set ["CellD"+CellCount.ToString()].CellBackgroundColor="#FF0000"; 
     // set ["CellE"+CellCount.ToString()].CellBackgroundColor="#FF0000"; 
     // set ["CellF"+CellCount.ToString()].CellBackgroundColor="#FF0000"; 
    } 

} 

ようになります。これが可能かどうかわからないル。あるいは、私がやりたいことと同等の方法があれば、私を助けてくれますか? :)ありがとう!

答えて

2
Sub backcolor() 
Range("a1:a10").Interior.ColorIndex = xlNone 
For Each cell In Range("a1:a10") 
    If cell.Value = "Sunday" Or cell.Value = "Saturday" Then 
     cell.Interior.ColorIndex = 3 
    End If 
Next cell 
End Sub 

現在の色のリスト

http://dmcritchie.mvps.org/excel/colors.htm

3

あなたがしたいのは、その値に基づいてセルの色を変更することだけです.Excelで条件付き書式を使用するだけで、プログラミングは必要ありません。 http://office.microsoft.com/en-us/excel-help/creating-conditional-formatting-:

+0

セカンドそれを見つけることができます式-HA001111661.aspx – Juliusz

+0

読み込み中ですが、ソースファイルを制御できません – datatoo

関連する問題