Application.Match making my head spin

Big Lar

Well-known Member
Joined
May 19, 2002
Messages
554
This code works to find the first 3 place winners and insert their winnings on my recap Sheets(“PAYOUTS”).

Code:
‘1st Flight Gross
If Sheets("1GROSS").[AB3] = "" Then
     Sheets("PAYOUTS").[M3:M150] = ""
Else
    temp = Application.Match(Sheets("1GROSS").[A3], Sheets("PAYOUTS").[B3].Resize(153), 0)
        Sheets("PAYOUTS").[M3] = Application.Index(Sheets("1GROSS").[AB3].Resize(153), temp)
End If


If Sheets("1GROSS").[AB3] = "" Then
     Sheets("PAYOUTS").[M3:M150] = ""
Else
    temp = Application.Match(Sheets("1GROSS").[A4], Sheets("PAYOUTS").[B3].Resize(153), 0)
        Sheets("PAYOUTS").[M4] = Application.Index(Sheets("1GROSS").[AB3].Resize(153), temp)
End If


If Sheets("1GROSS").[AB3] = "" Then
     Sheets("PAYOUTS").[M3:M150] = ""
Else
    temp = Application.Match(Sheets("1GROSS").[A5], Sheets("PAYOUTS").[B3].Resize(153), 0)
    Sheets("PAYOUTS").[M5] = Application.Index(Sheets("1GROSS").[AB3].Resize(153), temp)
End If


But, adding additional lines for Sheets(“2GROSS”) and (“3GROSS”) winners results in blank cells.
Can anyone explain or suggest a correction or better solution?

Code:
'2nd Flight Gross
If Sheets("2GROSS").[AB3] = "" Then
     Sheets("PAYOUTS").[N3:N150] = ""
Else
    temp = Application.Match(Sheets("2GROSS").[A3], Sheets("PAYOUTS").[B3].Resize(153), 0)
        Sheets("PAYOUTS").[N3] = Application.Index(Sheets("2GROSS").[AB3].Resize(153), temp)
End If


If Sheets("2GROSS").[AB3] = "" Then
     Sheets("PAYOUTS").[N3:N150] = ""
Else
    temp = Application.Match(Sheets("2GROSS").[A4], Sheets("PAYOUTS").[B3].Resize(153), 0)
        Sheets("PAYOUTS").[N4] = Application.Index(Sheets("2GROSS").[AB3].Resize(153), temp)
End If

If Sheets("2GROSS").[AB3] = "" Then
     Sheets("PAYOUTS").[N3:N150] = ""
Else
    temp = Application.Match(Sheets("2GROSS").[A5], Sheets("PAYOUTS").[B3].Resize(153), 0)
        Sheets("PAYOUTS").[N5] = Application.Index(Sheets("2GROSS").[AB3].Resize(153), temp)
End If

'3rd Flight Gross
If Sheets("3GROSS").[AB3] = "" Then
     Sheets("PAYOUTS").[O3:O150] = ""
Else
    temp = Application.Match(Sheets("3GROSS").[A3], Sheets("PAYOUTS").[B3].Resize(153), 0)
        Sheets("PAYOUTS").[O3] = Application.Index(Sheets("3GROSS").[AB3].Resize(153), temp)
End If

If Sheets("3GROSS").[AB3] = "" Then
     Sheets("PAYOUTS").[O3:O150] = ""
Else
    temp = Application.Match(Sheets("3GROSS").[A4], Sheets("PAYOUTS").[B3].Resize(153), 0)
        Sheets("PAYOUTS").[O4] = Application.Index(Sheets("3GROSS").[AB3].Resize(153), temp)
End If

If Sheets("3GROSS").[AB3] = "" Then
     Sheets("PAYOUTS").[O3:O150] = ""
Else
    temp = Application.Match(Sheets("3GROSS").[A5], Sheets("PAYOUTS").[B3].Resize(153), 0)
        Sheets("PAYOUTS").[O5] = Application.Index(Sheets("3GROSS").[AB3].Resize(153), temp)
End If
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--> OK, it turns out that code isn’t producing my desired result. Here’s what I’m attempting:

Sheets(“1GROSS”) A3:A150 is names, AB3:AB150 is numbers
Sheets(“PAYOUTS”) B3:B150 is same names in random order

Match the names and put the corresponding values from
(1GROSS) AB3:AB150 to (PAYOUTS) M3:M150

So, if Bill Smith is the name
And, his value in 1GROSS column AB is $5.00
Find Bill Smith in PAYOUTS and make his Column M cell value $5.00

Repeat this procedure for all names and values

<!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->
 
Upvote 0
To clarify:
Sheet(1GROSS) is:
COLUMNS
A.....AB
Bill.... 5
Andy..4
Sam...3
Jack...2
Joe....1

Before procedure:
Sheet(PAYOUTS)
COLUMNS
A.....M
Sam
Bill
Jack
Joe
Andy

After Procedure:
Sheet(PAYOUTS)
COLUMNS
A......M
Sam...3
Bill.....5
Jack...2
Joe....1
Andy..4
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top