+ Reply to Thread
Results 1 to 3 of 3

Use Max Function in VBA

Hybrid View

maacmaac Use Max Function in VBA 01-03-2012, 06:09 PM
Jack in the UK Re: Use Max Function in VBA 01-03-2012, 06:31 PM
OnErrorGoto0 Re: Use Max Function in VBA 01-03-2012, 07:17 PM
  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Use Max Function in VBA

    I am trying to use the following line of code to obtain the highest value in column L and keep getting an error. Tried using "worksheetfunction", "application.worksheetfunction", etc.
    
    newHHNumber = Application.Max(Range("L2:L" & LastRow)) + 1
    Last edited by maacmaac; 01-03-2012 at 09:32 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Use Max Function in VBA

    This shoudl do it - edit as required

    Option Explicit
     
    Sub jiuk_TEST_myMAX_FUNCTION()
    
    Dim myAnswer_MAX As Long
    myAnswer_MAX = WorksheetFunction.Max(Range("l1:l5000"))
        
    MsgBox myAnswer_MAX
    theEND_jiuk_TEST_myMAX_FUNCTION:
    '// jiuk - do something N/A
    Exit Sub
    
    End Sub

  3. #3
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Use Max Function in VBA

    Hi,
    Which error are you getting? Do you have any error values in that range?
    Good luck.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1