A列に名前があり、B列に次のような数字があります。
jimmy 4
jimmy 4
carl 8
john 8
ジミーの数を合計する必要があります。つまり、A列に同じ値がいくつかある場合、その名前のB番号の合計です。だからジミー= 8.どうすればいいですか?私はvbaが初めてなので、私にとって簡単なことはそれほど簡単ではありません:)
編集、マクロ:
Sub Sample()
Dim path As String
Dim openWb As Workbook
Dim openWs As Worksheet
Dim DataInizio As String
Dim DataFine As String
path = "C:\Me\Desktop\example.xls"
Set thiswb = ThisWorkbook
Set openWb = Workbooks.Open(path)
Set openWs = openWb.Sheets("details")
Set Logore = thiswb.Sheets("Log")
With openWs
start = CDate(InputBox("start (gg/mm/aaaa)"))
end = CDate(InputBox("end (gg/mm/aaaa)"))
Sheets("details").Select
LR = Cells(Rows.Count, "A").End(xlUp).Row
dRow = 2
For r = 2 To LR
If Cells(r, 1) >= start And Cells(r, 1) <= end Then
' Do un nome alle colonne nel file di log indicandone la posizione
ore = Range("K" & r)
nome = Range("J" & r)
totore = totore + ore
If ore <> 8 Then
Range("A" & r & ",J" & r & ",D" & r & ",K" & r).Copy Logore.Cells(dRow, 1)
rigatot = dRow
dRow = dRow + 1
End If
If nome <> Range("J" & r + 1) Then
If totore <> 40 Then
Logore.Cells(dRow, 5) = totore
End If
totore = 0
End If
End If
Next
thiswb.Sheets("Log").Activate
End With
openWb.Close (False)
End Sub