View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Vasant Nanavati Vasant Nanavati is offline
external usenet poster
 
Posts: 1,080
Default Code runs different in a commandbutton than a macro why?

(Yeah, yeah. I don't need to qualify rows.count, but I like to.)<<

And so your code won't break when the next Excel version allows different
worksheets to have different total rows! <vbg

--

Vasant



"Dave Peterson" wrote in message
...
After the correction posted by Vasant, there's no difference. But I like

that
style.

If I did this, it would look cleaner:

Dim rng As Range
Dim x As Long
Dim y As Long
Dim z As Long
Dim w As Long
x = 3: y = 5: z = 10: w = 15 'just numbers for testing

With Worksheets("Paid recievables")
Set rng = .Range(.Cells(x, y), .Cells(z, w))
End With

than

Set rng = Worksheets("paid recievables").Range _
(Worksheets("paid recievables").Cells(x, y), _
Worksheets("paid recievables").Cells(z,

w))

And I find I'm a lot less likely to leave an unqualified range this way.

(Yeah, yeah. I don't need to qualify rows.count, but I like to.)



Don Wiss wrote:

On Sat, 06 Dec 2003 10:13:35 -0600, Dave Peterson

wrote:

with worksheets("Paid Recievables")
set rng = .cells(.rows.count,1).end(xlup).offset(1,0)
end with


What do you gain by using those three lines instead of?

set rng = worksheets("Paid

Recievables").cells(.rows.count,1).end(xlup).offse t(1,0)

or?

rng = worksheets("Paid

Recievables").cells(.rows.count,1).end(xlup).offse t(1,0)

Don <donwiss at panix.com.


--

Dave Peterson