更改 MS Excel 2003 的背景
我是 c# 编码员,到目前为止,这是我所知道的表达我想要的内容的最佳方式。 我正在考虑在 microsoft 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";
}
}
我不确定这是否可行。或者如果有任何其他与我想做的事情相当的方法,你能帮助我吗? :) 谢谢!
I'm a c# coder and so far this is the best way I know to express what I wanted.
I am thinking of doing this code below on a microsoft excel 2003 worksheet.
Could this be possible?
1st step
if(CellA1 == "Sunday" || CellA1== "Saturday"){
// code to set background color of
// CellB1 to CellF1 to background color red
}
2nd step
// Execute this process from CellA1 until CellA10
for(CellA1 up to CellA10){
// do first step
}
So the code I wanted to do on MSExcel 2003 would look like this
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";
}
}
I'm not sure if this is possible. Or if there are any other ways equivalent on what I wanted to do, can you please help me. :) Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您只想根据单元格的值更改单元格的颜色,只需在 Excel 中使用条件格式即可,无需任何编程。
If all you want to do is change the color of a cell based on its value, just use conditional formatting in excel, no need for any programming.
您可以在此处找到颜色列表
http://dmcritchie.mvps.org/excel/colors.htm
You can find the list of colors here
http://dmcritchie.mvps.org/excel/colors.htm