View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Code runs different in a commandbutton than a macro why?

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