+ Reply to Thread
Results 1 to 20 of 20

detect and add the quantities of letters in their groups

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,318

    detect and add the quantities of letters in their groups

    detect and add the quantities of letters in their groups
    https://www.excelforum.com/attachmen...1&d=1551180540
    Attached Files Attached Files

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: detect and add the quantities of letters in their groups

    Does it need to be VBA?

    AW6: =COUNTIFS($I$4:$AU$4,AW$4,$I6:$AU6,"X")
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,318

    Re: detect and add the quantities of letters in their groups

    Does it need to be VBA? YES!please

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: detect and add the quantities of letters in their groups

    one of many ways to do it

    Sub X()
    
        Dim header As Range
        Dim data As Range
        Dim output As Range
        Dim rowIndex As Long
        Dim colIndex As Long
        Dim letterIndex As Long
        Dim letter As String
        Dim tally As Long
        
        Set header = Range("I4:AU4")
        Set data = Range("I6:AU7")
        Set output = Range("AW6")
        
        For rowIndex = 1 To data.Rows.Count
            For letterIndex = 1 To 4
                tally = 0
                letter = Chr(64 + letterIndex)
                For colIndex = 1 To data.Columns.Count
                    If header.Cells(1, colIndex) = letter Then
                        If Len(data.Cells(rowIndex, colIndex)) > 0 Then
                            tally = tally + 1
                        End If
                    End If
                Next
                output = tally
                Set output = output.Offset(0, 1)
            Next
            Set output = output.Offset(1, -4)
        Next
                    
    End Sub

  5. #5
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,318

    Re: detect and add the quantities of letters in their groups

    I put it in the worksheet, but it is not running! can you see why it is not performing?

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: detect and add the quantities of letters in their groups

    Why did you put the code in the worksheet module rather than a standard module?

    What error did you get?

    Post example of what you have done

  7. #7
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,318

    Re: detect and add the quantities of letters in their groups

    I put the macro in visual basic (modulo) gave the command execute, and nothing happens

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: detect and add the quantities of letters in their groups

    As you don't want to show me yours I will show you mine.

    Run the macro X to populate cells.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,318

    Re: detect and add the quantities of letters in their groups

    hello Andy has something strange in the macro, I did the correct procedures
    * the macro is not happening at all, it's not running, it's not doing anything, please !!

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: detect and add the quantities of letters in their groups

    Did you enable macros?

    Try clearing the output cells before running the code so you can see the new output.

  11. #11
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,318

    Re: detect and add the quantities of letters in their groups

    hello, ANDY POPE! I cleaned the cells, I did the procedures, but this one is running, can you do it on the planilia sent in the post? please

  12. #12
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: detect and add the quantities of letters in their groups

    I did use the file you posted. I simply copied the code into it and saved with the thread number and .xlsm file format

  13. #13
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,318

    Re: detect and add the quantities of letters in their groups

    hello ANDY !!!maybe it's a misunderstanding
    * the amcro has to do on all lines
    * those two are just an example
    and more every week I'll post new drawings
    * the macro has to do all blank, it's not doing this

  14. #14
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: detect and add the quantities of letters in their groups

    Not so much a misunderstanding as you never mentioned the amount of 'X' would change.

    Sub X()
    
        Dim header As Range
        Dim data As Range
        Dim output As Range
        Dim rowIndex As Long
        Dim colIndex As Long
        Dim letterIndex As Long
        Dim letter As String
        Dim tally As Long
        
        Set header = Range("I4:AU4") ' assume fixed location
        Set data = Range("I6:AU6")
        Set output = Range("AW6")
        
        Do While Application.CountA(data) > 0
            For letterIndex = 1 To 4
                tally = 0
                letter = Chr(64 + letterIndex)
                For colIndex = 1 To data.Columns.Count
                    If header.Cells(1, colIndex) = letter Then
                        If Len(data.Cells(rowIndex, colIndex)) > 0 Then
                            tally = tally + 1
                        End If
                    End If
                Next
                output = tally
                Set output = output.Offset(0, 1)
            Next
            Set output = output.Offset(1, -4)   ' move reference down a row
            Set data = data.Offset(1, 0)        ' move reference down a row
        Loop
                    
    End Sub

  15. #15
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,318

    Re: detect and add the quantities of letters in their groups

    the sum of the suit does not work,
    * the macro does not work, put it on the sheet
    no excel

  16. #16
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: detect and add the quantities of letters in their groups

    Sum and correction
    Sub X()
    
        Dim header As Range
        Dim data As Range
        Dim output As Range
        Dim rowIndex As Long
        Dim colIndex As Long
        Dim letterIndex As Long
        Dim letter As String
        Dim tally As Long
        Dim total As Long
        
        Set header = Range("I4:AU4") ' assume fixed location
        Set data = Range("I6:AU6")
        Set output = Range("AW6")
        
        Do While Application.CountA(data) > 0
            total = 0
            For letterIndex = 1 To 4
                tally = 0
                letter = Chr(64 + letterIndex)
                For colIndex = 1 To data.Columns.Count
                    If header.Cells(1, colIndex) = letter Then
                        If Len(data.Cells(1, colIndex)) > 0 Then
                            tally = tally + 1
                        End If
                    End If
                Next
                output = tally
                total = total + tally
                Set output = output.Offset(0, 1)
            Next
            output.Offset(0, 1) = total
            Set output = output.Offset(1, -4)   ' move reference down a row
            Set data = data.Offset(1, 0)        ' move reference down a row
        Loop
                    
    End Sub

  17. #17
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,318

    Re: detect and add the quantities of letters in their groups

    HELLO ANDY=It didn't work because it classed the X's as data, not the actual results. They were not all filled in for all the draws, so it stopped after 2 rows.
    I had to do formulas to put the Xs in.

  18. #18
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,318

    Re: detect and add the quantities of letters in their groups

    andy , andy!!It did not work because it classified the X as data, not actual results. They were not all filled for all raffles, so they stopped after 2 lines.
    * You have to make formulas to put the Xs. The macro depended on counting how many rows of X there were to work correctly you have to change to count how many RESULTS there are.

    Nor does the SUM part see this

  19. #19
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: detect and add the quantities of letters in their groups

    Sub X()
    
        Dim header As Range
        Dim data As Range
        Dim output As Range
        Dim rowIndex As Long
        Dim colIndex As Long
        Dim letterIndex As Long
        Dim letter As String
        Dim tally As Long
        Dim total As Long
        Dim drawData As Range
        Dim drawDataRow As Range
        Dim numberData As Range
        Dim xpos As Variant
        
        Set drawData = Range("A6").CurrentRegion
        
        Set header = Range("I4:AU4") ' assume fixed location
        Set numberData = Range("I5:AU5") ' assume fixed location
        Set data = Range("I6:AU6")
        Set output = Range("AW6")
        
        For Each drawDataRow In drawData.Rows
            
            For colIndex = 1 To drawDataRow.Columns.Count
                xpos = Application.Match(drawDataRow.Cells(1, colIndex), numberData, 0)
                data.Cells(1, xpos) = "X"
            Next
            
            total = 0
            For letterIndex = 1 To 4
                tally = 0
                letter = Chr(64 + letterIndex)
                For colIndex = 1 To data.Columns.Count
                    If header.Cells(1, colIndex) = letter Then
                        If Len(data.Cells(1, colIndex)) > 0 Then
                            tally = tally + 1
                        End If
                    End If
                Next
                output = tally
                total = total + tally
                Set output = output.Offset(0, 1)
            Next
            output.Offset(0, 1) = total
            Set output = output.Offset(1, -4)   ' move reference down a row
            Set data = data.Offset(1, 0)        ' move reference down a row
        Next
                    
    End Sub

  20. #20
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,318

    Re: detect and add the quantities of letters in their groups

    huu andy, perfect, magnificent work,
    * Correct, now it's working,
    thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. please, detect on each pair, * one of the 7 groups.
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-24-2019, 06:46 AM
  2. please detect the front double of the pick3 and see the amount of each groups.
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2019, 10:01 AM
  3. [SOLVED] detect, the double, frontal or rear, according to the 6 letters .
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 01-01-2019, 10:25 AM
  4. detect, even / odd color and letters in matrix,
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-12-2018, 05:08 PM
  5. [SOLVED] please!!! locate the 18 patterns of the number quantities of the 3 letters.
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-05-2018, 11:15 AM
  6. Replies: 11
    Last Post: 06-24-2016, 08:43 AM
  7. [SOLVED] Using VBA to detect separate groups of rows.
    By nt85 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-05-2014, 11:00 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1