2016-05-12 32 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