# Thread: Count totals from one sheet and put on another Thanks: 0 Likes: 0

1. ## Count totals from one sheet and put on another

Hi - I don't have any code for this because i'm not sure where to start. On Workbook1.Sheet1 is a lot of data from column A:O. Workbook2 has sheets with names that correspond to column O on Workbook1.Sheet1. I would like to put the date the procedure is run in column A of each corresponding sheet in Workbook2. I then want to count all the rows in column N that match the sheet name and put that in column B. Column C would count the number of rows with "Cookie" in Column M that also matches the sheet name. Each time the procedure is run, it would put a new entry on the next row. So A5 would have 8/8/2019 and then the counts. When i run it tomorrow A6 will start with 8/9/2019 and the counts. Hope I explained that well enough. Is that doable?

2. ## Re: Count totals from one sheet and put on another

This is code I came up with and it's working. I need to add the date portion in and add to next row part. Is there a way to say put the count on the sheet named apple? and then any other fruit count on the same named sheet? thanks!
Code:
```Dim wb1 As Workbook
Dim ws1 As Worksheet

Set wb1 = Workbooks("Workbook1")
Set ws1 = wb1.Worksheets("Sheet1")

With ws1
Dim x As Long
x = Sheet23.Range("A" & Rows.Count).End(xlUp).Row
If x < 1 Then x = 1
.Range("A5") = Application.WorksheetFunction.CountIf(Sheet23.Range("N2:N" & x), "Apples")
End With

With Sheet23
Dim cnt As Integer
cnt = 0
For i = 1 To 100
If Cells(i, 14).Value = "Apples" And Cells(i, 13).Value = "Green" Then
cnt = cnt + 1
End If
Next i
End With

ws1.Range("B5").Value = cnt```