View Single Post
  #5   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?

set rng = worksheets("Paid
Recievables").cells(.rows.count,1).end(xlup).offse t(1,0)<<

Should be:

Set rng = Worksheets("Paid
Recievables").Cells(Rows.Count,1).End(xlUp).Offset (1,0)

No period before Rows, otherwise your syntax will fail.

rng = worksheets("Paid

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

Will not work. For a range (or any object), you have to use Set to assign a
variable to it.

--

Vasant


"Don Wiss" wrote in message
...
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.