필터 지우기
필터 지우기

excel offset using in matlab question with code in

조회 수: 3 (최근 30일)
Nan Shen
Nan Shen 2011년 8월 2일
my 'month' is in cell A1, my target cell is A2, my code is listed below.
objExcel = actxserver('excel.application');
set(objExcel, 'Visible',1);
sheetName = 'DPLLC';
objSheet = objExcel.Worksheets.get('Item', sheetName);
first_m = objSheet.Range('A:Z').Find('month').offset(2,1).Address;
but give me error like ??? '??? Index exceeds matrix dimensions.'
  댓글 수: 5
Oleg Komarov
Oleg Komarov 2011년 8월 2일
With the code button: http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question. Thanks, it's already more readable.
Oleg Komarov
Oleg Komarov 2011년 8월 2일
Can't make it work...I suggest to retrieve the address and apply the offset with matlab, you can search one of the submissions on the FEX to do that.

댓글을 달려면 로그인하십시오.

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 8월 2일
According to the Excel VB reference, 'Offset' is a property, not a method. But in Excel VB, it seems working like a method, such as ActiveCell.Offset(3,3).Activate. But in MATLAB, 'Offset' is a property of the Range object and it returns the same Range object.
I guess you could get the address first, do the offset and then apply range.
  댓글 수: 2
Nan Shen
Nan Shen 2011년 8월 2일
but when I run: first_m = objSheet.Range('A:Z').Find('month').offset(1,1).Address;, it works..., I will try your suggestion.
Fangjun Jiang
Fangjun Jiang 2011년 8월 2일
Yes, but this 'Offset' is always one element, same is for 'Cells'. Try this:
get(objSheet.Range('A:Z').Find('month'),'Value')
get(objSheet.Range('A:Z').Find('month').Offset(1,1),'Value')
get(objSheet.Range('A:Z').Find('month').Cells(1,1),'Value')
They are all the same.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by