Cell Formatting From C++ output

lserrano

New Member
Joined
Feb 20, 2002
Messages
2
Hello,

I have a test program that I worte in C++, which outputs a bunch of measurement data into an Excel format with an "xls" extention. Is there a way to have my program append commands that would format the cell "color" based on measurement results? This would be conditional formatting that is performed when the file is opened.

I appreciate any suggestions!
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Thanks Nate,

But that requires the conditional format to be performed by the user, after the file has been opened. As an ex. if my data is less than zero, I would like to use something like "=format_cell("color",RBG)" to be run at file open.

Hope that makes sense.
 
Upvote 0
Well, if it's a new file, then yes. But once you layer the format on, then it's there and dynamic. So you're saying it's a new workbook....The plot thickens....
 
Upvote 0
Something along these lines may work. When the workbook opens, this will test a range and fill it in accordingly:

sub auto_open()
For Each cell In Range("A1:C4")
if cell.value < 1000
cell.Interior.ColorIndex = 28
end if
If cell.Value >= 1000 Then
cell.Interior.ColorIndex = 6
end if
Next cell
end if

End Sub


I haven't tested this so hopefully it's all good. Cheers, Nate
 
Upvote 0

Forum statistics

Threads
1,214,518
Messages
6,119,996
Members
448,935
Latest member
ijat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top