View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Formula using VBA

Or the more flexible:

Worksheets("Pricing").Cells(Rows.Count,"J").End(xl Up).Row

As long as a worksheet will be active. (all worksheets have the same number
or rows). More flexible because it will work with xl95 and earlier as well
(which may not be a consideration).

or

With Worksheets("Pricing")
lastRow = .Cells(.Rows.count,10).End(xlup).Row
End With

--
Regards,
Tom Ogilvy

"Harald Staff" wrote in message
...
"Angeliki" wrote in message
...
Set lastrow

=Worksheets("Pricing").Cells(Worksheets("Pricing") .Rows.Count,"A").End(xlUp)
..Row
Do you recognise any mistake in my code?


That would return the last cell in A column. Try J:


=Worksheets("Pricing").Cells(Worksheets("Pricing") .Rows.Count,"J").End(xlUp)
..Row

or preferrably the simpler

=Worksheets("Pricing").Cells(65536, "J").End(xlUp).Row

--
HTH. Best wishes Harald
Followup to newsgroup only please.