View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Can someone explain why?

Bobby,

Well it depends on your definition of 'Doesn't work'.

Both sub returns the maximum value in the range rngMax, what do you expect
them to do? What result are you getting?

Mike


"Bobby" wrote:

Hi,
Here is the situation:
I use EXCEL 2003

If I apply the following it does not work:
-------------------------------------------------------

Sub test()
Dim maxnumber As Integer, rngMax As Range

Sheets("Planif-max52").Select
Set rngMax = Worksheets("Rap-ELC").Range("B2:B53")
maxnumber = Application.WorksheetFunction.Max(rngMax)
MsgBox maxnumber

End Sub

But this does with the ActiveSheet.Range
--------------------
Sub test()
Dim maxnumber As Integer, rngMax As Range

Sheets("Planif-max52").Select
Set rngMax = ActiveSheet.Range("B2:B53")
maxnumber = Application.WorksheetFunction.Max(rngMax)
MsgBox maxnumber

End Sub


P.S: The column is define as General

Thank's ahead