Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub LisaaVE()
- Dim currentRow As Long, lastRow As Long
- Dim sh As Worksheet
- Dim currentRowTilastot As Long, lastRowTilastot As Long
- Set sh = ActiveSheet
- currentRowPaikalla = 2
- lastRowPaikalla = sh.Cells(sh.Rows.Count, "B").End(xlUp).Row
- lastRowTilastot = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
- ' xCell paikallaolleet
- For Each xCell In sh.Range("B2:B" & lastRowPaikalla)
- ' Aloitetaan etsimään riviltä 2
- currentRowTilastot = 2
- ' pCell pelaaja
- For Each pCell In Sheets("Sheet1").Range("A2:A" & lastRowTilastot)
- If pCell.Value = xCell.Value Then
- ' Lisätään pelaajalle +1
- Sheets("Sheet1").Range("D" & currentRowTilastot).Value = Sheets("Sheet1").Range("D" & currentRowTilastot).Value + 1
- Exit For ' Lopetetaan loop
- End If
- currentRowTilastot = currentRowTilastot + 1
- Next pCell
- currentRowPaikalla = currentRowPaikalla + 1
- Next xCell
- Sheets("Sheet1").Range("M2").Value = Sheets("Sheet1").Range("M2").Value + 1
- End Sub
- Sub LisaaOmat()
- Dim currentRow As Long, lastRow As Long
- Dim sh As Worksheet
- Dim currentRowTilastot As Long, lastRowTilastot As Long
- Set sh = ActiveSheet
- currentRowPaikalla = 2
- lastRowPaikalla = sh.Cells(sh.Rows.Count, "B").End(xlUp).Row
- lastRowTilastot = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
- ' xCell paikallaolleet
- For Each xCell In sh.Range("B2:B" & lastRowPaikalla)
- ' Aloitetaan etsimään riviltä 2
- currentRowTilastot = 2
- ' pCell pelaaja
- For Each pCell In Sheets("Sheet1").Range("A2:A" & lastRowTilastot)
- If pCell.Value = xCell.Value Then
- ' Lisätään pelaajalle +1
- Sheets("Sheet1").Range("B" & currentRowTilastot).Value = Sheets("Sheet1").Range("B" & currentRowTilastot).Value + 1
- Exit For ' Lopetetaan loop
- End If
- currentRowTilastot = currentRowTilastot + 1
- Next pCell
- currentRowPaikalla = currentRowPaikalla + 1
- Next xCell
- Sheets("Sheet1").Range("L2").Value = Sheets("Sheet1").Range("L2").Value + 1
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement