Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
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
Author: duncanb7 replied at 2024-06-25 04:32:37
Hi,
copy after/ before referres to the order the new sheet will be created.
copy after creates the new sheet after the already existing one, while
copy before creates the new sheet before the already existing one.
you can experiment a lot with recording a macro, then check the source of it.
Regards,
István
Accepted Solution
Expert: nagyistvan replied at 2024-06-25 04:21:18
250 points EXCELLENT
Hi,
copy after/ before referres to the order the new sheet will be created.
copy after creates the new sheet after the already existing one, while
copy before creates the new sheet before the already existing one.
you can experiment a lot with recording a macro, then check the source of it.
Regards,
István
Expert: nagyistvan replied at 2024-06-25 04:18:51