2016-05-12 29 views
-3

我可以用vba來計算玩家在賽季中的進球數量。我已經有了一個工作開始,用戶首先被問到球員名字何處添加目標,然後詢問目標數量。但是如果我爲同一名球員添加更多進球數,我希望之前的進球數增加到新號碼 例子球員在第一場比賽中進球3次,而下週他進球總數爲4球進球數爲7 我想要數字7被證明不是4號Vba計數器用於計算玩家目標數量

回答

0

我想這是你想要什麼:

Sub maalit() 

    Dim ws As Worksheet 
    Dim lRow As Long 
    Dim strSearch As String 
    Set ws = Worksheets("Data") 

    Dim etsi As String 
    etsi = InputBox("Etsi Jäsen", "maalien lisääminen") 'asks the players name 


    If Trim(etsi) <> "" Then 
     With Sheets("Data").Range("A:A") 
      Set Rng = .Find(What:=etsi, _ 
          After:=.Cells(.Cells.Count), _ 
          LookIn:=xlValues, _ 
          LookAt:=xlWhole, _ 
          SearchOrder:=xlByRows, _ 
          SearchDirection:=xlNext, _ 
          MatchCase:=False) 
      If Not Rng Is Nothing Then 

    tulos = InputBox("Anna pelaajan maalienmäärä", "maalien lisääminen") 
    'Rng.Value = tulos  'asks the number of goals but this is the problem place the bacause it adds them to the wrong column i want them to be in column G 
    Rng.Offset(0, 1).Value = Rng.Offset(0, 1).Value + tulos 


     Else 
       MsgBox "Jäsentä ei löytynyt" 
      End If 
     End With 
    End If 
End Sub 

代碼是基於你的last question