Object definition and structure, with variables
And if you will store a row number in the variable, better to use a type
Long, or it might overflow.
--
HTH
RP
(remove nothere from the email address if mailing direct)
"NickHK" wrote in message
...
Neal,
Small point, but fromrow is declared as a Variant, whilst torow is an
Integer, which is not what you mean, I think.
You need to explicitly state the type of each variable, otherwise it
defaults to a Variant.
i.e. Dim fromrow as Integer
Dim torow As Integer
NickHK
"Neal Zimm" wrote in message
...
I tried to define an object representing a variable number
of rows that are to be cut and inserted into another sheet.
I got a type mismatch error on the code below.
In the module where this code is going to go,
the variables fromrow and to row are available and
'working'. I am a novice at 'object definition'.
Help will be appreciated.
Dim insertrange As range
Dim fromrow, torow As Integer
fromrow = 21: torow = 40
Set insertrange = Rows("&fromrow:&torow")
' Rows("21:40").Select trying to 'replace' this line of code
insertrange.Select 'with this line of code
Selection.Cut
Sheets("new").Select
range("A41").Select
Selection.Insert Shift:=xlDown
--
Neal Z
|