+ Reply to Thread
Results 1 to 5 of 5

VBA Macro help to return maximum value in text form

  1. #1
    Registered User
    Join Date
    07-15-2009
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    20

    Smile VBA Macro help to return maximum value in text form

    Hello everyone,
    I am a novice to VBA in excel, i have a table of more then 5000 rows. I would like to find a maximum value from each row and return the column title as "GL_Weld" or "Bend" or "Header" into another worksheet cell.

    i.e First Row max value = 0.011510 should return "Bend" into another worksheet

    GL_Weld Bend Header
    0.000170 0.011510 0.000500
    0.000000 0.000780 0.000000
    0.000240 0.011070 0.000480
    0.000000 0.000660 0.000000
    0.000000 0.003770 0.000000
    0.000000 0.000010 0.000000
    0.000280 0.010870 0.000480
    0.000000 0.000710 0.000000
    0.000200 0.011290 0.000490
    0.000000 0.000840 0.000000
    0 0 0.00002
    0 0.00031 0.00001
    0 0 0.00004
    0 0.0003 0.00002
    0 0 0.00001
    0 0.00027 0.00003
    0 0 0.00002
    0 0.00026 0.00004

    Can someone help please. Thanks in advance!
    Last edited by khanumair50; 07-15-2009 at 11:38 AM.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: VBA Macro help to return maximum value in text form

    Could you use this formula on the other sheet and just return the matching header? See Sheet3 in the attachment.

    =INDEX(Sheet2!$A$1:$C$1,1,MATCH(MAX(Sheet2!A2:C2),Sheet2!A2:C2,0))

  3. #3
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: VBA Macro help to return maximum value in text form

    You seem to have posted the same question twice?

  4. #4
    Registered User
    Join Date
    07-15-2009
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: VBA Macro help to return maximum value in text form

    Thanks palmetto,

    I am actually trying to write a macro. But i'm having problems defining range with recognition of decimal data format and worksheets, like to pick the data from worksheet called "DATA" and return it into worksheet called "RESULTS".

    Please look at the following code and see if you can help. I would really appreciate that.

    Sub maxvaluemacro()
    Dim Rng As Range, Dn As Range, Mx As Long, Col As String
    Set Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
    For Each Dn In Rng
    Mx = Application.Max(Dn.Resize(, 4))
    Select Case Mx
    Case Is = Dn.Offset(, 0): Col = "GL_Weld"
    Case Is = Dn.Offset(, 1): Col = "Bend"
    Case Is = Dn.Offset(, 2): Col = "Header"
    End Select
    Dn.Offset(, 4) = Col
    Next Dn
    End Sub

  5. #5
    Registered User
    Join Date
    07-15-2009
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: VBA Macro help to return maximum value in text form

    Sorry, i just wanted to rephrase the question. But intead end up posting a new thread. I would close the previous one.

+ 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