View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Setting a Range depending on variables

You should use

With Sheets("data")
.Range(.Cells(410, nrmess * 3 + 12), .Cells(415,nrmess * 3 + 12))
End With

but it may be that nrmess * 3 + 12 is greater than 255


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"mazo" wrote in message
ups.com...
Hi

Can somebody help me?
I have two expressions that seem similar to me. But one isn't working.


("rowstart" and "nrmess" are both integer variables with positive
values;
"rng" and "rng2" are both "dim as range")

This works:

Set rng = Measurement.Range(Cells(4070 + rowstart, 4), Cells(4120 +
rowstart, 4))

This doesn't work:

Set rng2 = Sheets("data").Range(Cells(410, nrmess * 3 + 12), Cells(415,
nrmess * 3 + 12))

Can somebody tell me, what is the reason??

Thank you