Count totals from one sheet and put on another
Results 1 to 2 of 2

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

  1. #1
    Board Regular
    Join Date
    Oct 2009
    Posts
    491
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default 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. #2
    Board Regular
    Join Date
    Oct 2009
    Posts
    491
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default 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
    Last edited by helpexcel; Aug 9th, 2019 at 09:41 AM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •