| |

VerySource

 Forgot password?
 Register
Search
View: 1293|Reply: 4

Super weird issue with VBA Range replication

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-13 22:30:02
| Show all posts |Read mode
xlsheet_finance.Range ("A1: R4, A6: R6, A10: R10"). Copy
Workbooks.Add
Sheets ("sheet1"). Paste

The goal you want to achieve: Copy the first to fourth, sixth, and tenth lines of the current work area xlsheet_finance to the new worksheet1 work area of ​​the Excel file.

Problem encountered: After running, all lines from line 1 to line 10 were copied. If it is copied to a different workspace of the same EXCEL file as xlsheet_finance, there is no problem. It is the strange phenomenon that all ten lines are copied when it is copied to an external Excel file.

Have you encountered this problem?
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-15 20:45:01
| Show all posts
It seems that discontinuous areas should be copied separately, otherwise errors may occur
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-4-17 17:00:01
| Show all posts
But I tried copying discontinuous areas in different workspaces of the same EXCEL file, everything works fine

The problem is that when copying between different EXCEL files, it is always copied to a continuous area by default

Depressed, if this function cannot be implemented now, it will make my VBA automatic program one less bright spot ~~

Everyone, please help me to investigate, do you need to pay special attention to it?

Microsoft's Office should not be so mentally retarded?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-23 17:30:02
| Show all posts
Another easy way is to copy the first line to the tenth line, and then delete the lines you do n’t need.
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-15 15:15:02
| Show all posts
After I copy to a new file, if I delete the lines that I don’t need, there will be no continuity in the middle, and it will be ugly for users to open the document

And the target rows I copied are all dynamic, and I can’t know in advance which ones I don’t need ^_^

Think again, why do I use VBA code to copy from one document to another document and copy the intermediate lines that I don’t need? There is no such problem in a document, VBA code can normally copy and paste discontinuous line records ~~
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list