필터 지우기
필터 지우기

How to find the first column without values in excel?

조회 수: 2 (최근 30일)
osminbas
osminbas 2012년 4월 18일
Hello,
I have an Excel worksheet where I have a certain number of columns of data. I am trying to find the first column which does not have any data so that I can write a vector in that column using xlswrite. I appreciate any help.

채택된 답변

Richard de Garis
Richard de Garis 2012년 4월 18일
You can try the Excel Range.End property, starting with a cell in a range beyond your data that you know is empty and look back from there. e.g.
Excel = actxGetRunningServer('Excel.Application');
xlworkSheet = Excel.ActiveWorkbook.Worksheets.Item('worksheet_name');
% Excel enumeration according to the help documentation
xlToLeft = -4159;
columnNo = xlworksheet.Range('AAA1').End(xlToLeft);
firstEmptyCol = xlworksheet.Range('A1').offset(0,columnNo-1);
  댓글 수: 1
osminbas
osminbas 2012년 4월 18일
Hi Richard,
Thank you. I actually used
Columns={'A','B','C'....}
for hh=1:15;
ColNum=strcat(Columns(hh),':',Columns(hh));
Test=xlsread(filePattern4{1,1},ColNum{1,1});
if numel(Test)==0;
break
end
end
And I used the hh value as the next column: Columns(hh)
Anyway, thank you.

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

추가 답변 (0개)

카테고리

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