Copy and Paste Excel Sheet into New WorkBook

조회 수: 69(최근 30일)
Logan Stetsko
Logan Stetsko 2015년 7월 7일
답변: Pruthvi G 2019년 9월 30일
I have two excel files:
file1.xlsx
file2.xlsx
file1.xlsx has a formatted sheet that I want to copy and paste into sheet 2 of a new workbook: file2.xlsx.
Basically I want to copy a sheet from one book to another.
This is what I have so far( I have tried to modify what I've found from other Threads)
Excel = actxserver('excel.application');
wkbk = Excel.Workbooks.Open('file1');
wksheet = wkbk.Worksheets.Item('Sheet1');
wksheet.Copy(wksheet);
wkbk = Excel.Workbooks.Open('file2.xlsx');
newSheet=wkbk.Worksheets.Item('Sheet2');
newSheet.Name='140C';
wkbk.Save
Excel.Quit
  댓글 수: 3
Mario Chiappelli
Mario Chiappelli 2019년 7월 19일
Something like this is best suited for VBA, I would recommend exploring how to use that.

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

답변(1개)

Pruthvi G
Pruthvi G 2019년 9월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by