フィルターのクリア

How can I determine excel range by column numbers in mscript?

26 ビュー (過去 30 日間)
dhkim
dhkim 2022 年 7 月 11 日
回答済み: Saffan 2023 年 8 月 30 日
For example I want to set the range Range('A1') as Cell(1,1).
How can I switch the code below by column numbers?
eSheet.Range('A1').Value = 1;

回答 (1 件)

Saffan
Saffan 2023 年 8 月 30 日
Hi,
To access the excel column using column number instead of column name, you can use “xlsColNum2Str” method from File Exchange as shown in the following code snippet:
% Set the column number
columnNumber = 1;
% Convert column number to column letter using xlsColNum2Str function
columnName = xlsColNum2Str(columnNumber);
% Set the row number
rowNumber = 1;
% Create the complete cell reference string
cellReference = [columnName{1}, num2str(rowNumber)];
% Set the value of the cell using the complete reference
eSheet.Range(cellReference).Value = 1;
The “xlsColNum2Str” method takes column number as input and gives column name as the output. You can get the script of the method from here:

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by