+ Reply to Thread
Results 1 to 2 of 2

Tally Macro: Broken Code

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Tally Macro: Broken Code

    The following code was used to run through a string of WS and count all items (exception of the header row located in Row1 on each sheet) and return count to cell D33 on sheet "ARG Home". As well it would count all items that have "No" listed in column with title "Completed" in Row1 and return to cell I33 on sheet "ARG Home". It worked fine but I handed it off to another employee and no they state it has issues unfortunately of which I cant locate.

    The total in D33 seems accurate it is the return value in I33 that seems off and as well it provides (2) prompts that "One or More headings not found" which I am thinking is my problem. What should I be looking for that is different in the "headings" based on this code:

    HTML Code: 

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,235

    Re: Tally Macro: Broken Code

    First, it is not practical to troubleshoot this without your data. Can you provide a sample file with data that causes the problem?

    Second, it would be much easier to read your code if you used indentation to show the control structure, like this:
    Private Sub CommandButton4_Click()
    
       Dim NoTot As Integer
       Dim tot As Integer
       Dim oSheet As Worksheet
       Dim oOutput As Worksheet
       Dim total As Integer
       Dim oCell As Range
       Dim oSet As Long
       
       On Error Resume Next 'In case any sheet has no data in A
       Set oOutput = ThisWorkbook.Worksheets("ARG Home")
       For Each oSheet In ThisWorkbook.Worksheets
          Select Case oSheet.Name
             'Change sheet names (next line) to actual names
             Case "ARG Home", "Tracking Form"
             Case Else
                oSet = Application.Match("Completed", oSheet.Range("1:1"), 0) - 1
                tot = oSheet.Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count - 1
                total = total + tot
                For Each oCell In oSheet.Range("A:A").Cells.SpecialCells(xlCellTypeConstants)
                   If oCell.Row > 1 Then
                      If UCase(Trim(oCell.Offset(0, oSet))) = "YES" Then
                         'If cell value is "Yes" color should be NO FILL????
                         oCell.Offset(0, oSet).Interior.ColorIndex = xlColorIndexNone
                      Else
                         'If cell value is NOT "Yes" cell should have YELLOW ???.
                         oCell.Offset(0, oSet).Interior.ColorIndex = 6
                         NoTot = NoTot + 1
                      End If
                   End If
                Next oCell
          End Select
       Next oSheet
       oOutput.Range("I33").Value = NoTot
       oOutput.Range("D33").Value = total
       
    End Sub
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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. Copy web page with VBA code- broken
    By flaviu123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-22-2014, 09:45 AM
  2. VBA code to validate Broken links of a web page
    By Shanthuday in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-28-2013, 08:25 AM
  3. Sheet event code: find last row broken?
    By jrussell in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-24-2009, 03:37 PM
  4. [SOLVED] create tally sheet for positions- insert names and tally #
    By tally sheets in forum Excel General
    Replies: 0
    Last Post: 04-11-2006, 04:45 PM

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