How to highlight specifics excel cell using index numbers using actxserver Matlab
14 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I was wondering whether someone could help me with an small part of code than I need to develop.
I have to highlight specifics cells in excel using matlab. These cells are based on a condition that I have previously applied in my code and that will provide me a vector where the condition is not met and then I require to highlight in excel these cells using actxserver. I have been looking for other answers and I could not get info. of how to do this. VBA you can use Cells command to select specifics cell based on index and not range. It is working if I use range but in my case the range will be changed depending on the work, so index is the more appropiate.
Thank you very much.
Example vector of 1X178 and I have found that values at 2 6 9 12 14 19 do not meet condition, therefore, I would like to highlight in Excel.
I have tried this piece of code:
vector_column=[2 6 9 12 14 19];
Excel=actxserver('excel.application') % Active server
WB=Excel.Workbooks.Open(fullfile('C:\Users\Cruz\Desktop\New folder','test_check2.xlsx'),0,false); %Open workbook
for j=1:size(vector_column,2)
WB.Worksheets.Item(1).Cells(17,vector_column(j)).Interior.Color=hex2dec('00FF00'); % Tried to change colour of excel cells at row 17 and columns number specify in the vector
end
WB.Save();
WB.Close();
Excel.Quit();
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Use COM Objects in MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!