Asked by duncanb7
at 2024-06-25 04:06:57
Point:250 Replies:3 POST_ID:828350USER_ID:11059
Topic:
Visual Basic Programming;;
I have tried to open a excel file and copy one of its sheets into other new sheet in the same file,
for example, the code as follows
'"template" sheet is in out.xls and is copied into new sheet call "result"
Workbooks.Open Filename:= _
"d:out.xls"
Workbooks("out").Sheets.Add.Name = "Result"
Sheets("template").Select
Sheets("template").Copy
Sheets("Result").Select
Sheets("Result").Paste
The code is fail and have run-time error, the paste operation is not done on "Result" sheet but it paste in on other new sheet "BOOK2" created by Excel 2003 instead, Please advise what is wrong with these.
The other question what is meaning of .copy after:= or .copy before ... Where I could know the defintion of
copy synax in VBA ?
BR
Duncan
for example, the code as follows
'"template" sheet is in out.xls and is copied into new sheet call "result"
Workbooks.Open Filename:= _
"d:out.xls"
Workbooks("out").Sheets.Add.Name = "Result"
Sheets("template").Select
Sheets("template").Copy
Sheets("Result").Select
Sheets("Result").Paste
The code is fail and have run-time error, the paste operation is not done on "Result" sheet but it paste in on other new sheet "BOOK2" created by Excel 2003 instead, Please advise what is wrong with these.
The other question what is meaning of .copy after:= or .copy before ... Where I could know the defintion of
copy synax in VBA ?
BR
Duncan