football form table from results

Peterfc2

Active Member
Joined
Jan 2, 2004
Messages
394
Office Version
  1. 2013
Platform
  1. Windows
http://www.blueswayedviews.co.uk/peterfc2/capture1.jpg

Look at the link please.

What I want to happen is it to fill the data in the yellow area.
i.e. Tom has played 3 game giving W W L. (I've typed this data in to show I want.)
Anyone know how this can be done please. Tried index match but failed to sort it out.
 

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
Please try this macro on a copy of your worksheet,
Code:
Sub fillintheresults()
    Range("L2:XFD50").ClearContents
    
    lastrow = Range("B1").End(xlDown).Row
    lastrow2 = Range("K2").End(xlDown).Row
    
    For i = 2 To lastrow2
        For j = 2 To lastrow
            lastcol = Range("xfd" & i).End(xlToLeft).Column
            If Cells(j, 2).Value = Cells(i, 11).Value Then
                Cells(i, lastcol + 1).Value = Cells(j, 8).Value
            End If
            If Cells(j, 6).Value = Cells(i, 11).Value Then
                Cells(i, lastcol + 1).Value = Cells(j, 9).Value
            End If
        Next j
    Next i
End Sub
 
Upvote 0
Please try this macro on a copy of your worksheet,
Code:
Sub fillintheresults()
    Range("L2:XFD50").ClearContents
    
    lastrow = Range("B1").End(xlDown).Row
    lastrow2 = Range("K2").End(xlDown).Row
    
    For i = 2 To lastrow2
        For j = 2 To lastrow
            lastcol = Range("xfd" & i).End(xlToLeft).Column
            If Cells(j, 2).Value = Cells(i, 11).Value Then
                Cells(i, lastcol + 1).Value = Cells(j, 8).Value
            End If
            If Cells(j, 6).Value = Cells(i, 11).Value Then
                Cells(i, lastcol + 1).Value = Cells(j, 9).Value
            End If
        Next j
    Next i
End Sub


Range("L2:XFD50").ClearContents
METHOD RANGE OF OBJECT GLOBAL FAILED

Get the above error!
Any ideas?
 
Upvote 0
Well, that line only seeks to clear the "result range" of any data prior to running the macro. Lets try this, comment that line out of the macro, manually delete the W,W,L,L and run the code again
 
Upvote 0
Sorry. Maybe I've not made it clear the results I want. I'm happy with homewld and awaywld. They work fine when I add more results.
So I recap..
In K2 is TOM. The data in L2 M2 N2 I have typed in to show the thing I'm after. o.k.
So toms form this season is..
Row 2 he won (his first game)-Row 4 he won (his second game)-Row 5 he lost ( his third game)
So in L2 WOULD BE W - M2 WOULD BE W - N2 WOULD BE L
If tom draws his fourth game then O2 should equal D.
ETC.

Hope that clarifies the what i would like to do.
 
Upvote 0
I do get what you want, see the results as obtained from my macro after I added 2 more matches to the already existing ones
Excel 2010
ABCDEFGHIJKLMNO
1HomeAwayHimeResAwayRes
2tom20sumWLtomWWLW
3pat22sumDDpatDLL
4tom32patWLsumLDD
5pot40tomWLpotWD
6tom32patWL
7pot11sumDD
Sheet4
 
Upvote 0
o.k. I'll have a play.
lastcol = Range("xfd" & i).End(xlToLeft).Column
I comment out the clearing bit.
stops at Range"fxd"

You running the macro has first written? I'm excel 2000 ( I know, lol) should it still work.
 
Upvote 0
Really is what I asked for and works for you. Will have another go later. Thanks
 
Upvote 0
lastcol = Range("xfd" & i).End(xlToLeft).Column

Right had a play with it and its the "xfd" that the macro stops at. Baffles me. I'm open to suggestions?
 
Upvote 0

Forum statistics

Threads
1,214,661
Messages
6,120,796
Members
448,994
Latest member
rohitsomani

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