Hi all,
Sorry for asking such a simple question, but I'm trying to increase the efficiency of a macro I've written in Excel.
It's designed to copy an unknown number of rows from one sheet to another, and currently does so with a for...next loop:
The problem is that this is hugely inefficient, often taking over a minute to run, yet it would take almost no time if I could copy it without the loop, as a range of rows; effectively, something like this:
Unfortunately, the line
produces a type mismatch error, and I can't figure out the syntax to make it select a range in the way it does if I use code like
I've tried every form of syntax I can think of, and none of it seems to work - everything either gives a type mismatch error when I run the macro, or a compile error.
EDIT: I have Saurus, Skink and Slann all declared as Long currently, if that makes a difference.
Any ideas on how I could get the effect I'm after? Should I be using an entirely different system to copy the lines across?
Thanks in advance.
Sorry for asking such a simple question, but I'm trying to increase the efficiency of a macro I've written in Excel.
It's designed to copy an unknown number of rows from one sheet to another, and currently does so with a for...next loop:
Code:
For slann = Saurus To Skink Step -1
Sheet1.Select
Rows(slann).Select
Selection.Copy
Sheet6.Select
Rows("9").Select
Selection.Insert Shift:=x1Down
Next
The problem is that this is hugely inefficient, often taking over a minute to run, yet it would take almost no time if I could copy it without the loop, as a range of rows; effectively, something like this:
Code:
Rows("Saurus:Skink").Select
Selection.Copy
Sheet6.Select
Rows("9").Select
Selection.Insert Shift:=x1Down
Unfortunately, the line
Code:
Rows("saurus:Skink").Select
Code:
Rows("1:2").Select
EDIT: I have Saurus, Skink and Slann all declared as Long currently, if that makes a difference.
Any ideas on how I could get the effect I'm after? Should I be using an entirely different system to copy the lines across?
Thanks in advance.