Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>UPDATED SOLUTION:</strong></p> <p>After discussion in chat with OP it was decided that pure formula solution is fine - below are formulas / actions to do on the <strong>separate</strong> sheet starting <code>A1</code>:</p> <ol> <li>Row A will be resulting table header: in <code>A1</code> I added <code>Agent Name / Release Code</code>, and starting <code>B1</code> there's a list of all available <code>Release Code</code> values (easily got using <code>Remove Duplicates</code>).</li> <li>I defined the following named ranges for the simplicity and effectiveness (since initial data is NOT static): <code>AgentNames=OFFSET('Agent State'!$B$2,0,0,COUNTA('Agent State'!$B:$B)-1,1)</code> - this will return the range of names on the initial sheet <strong>excluding</strong> the header; <code>TimeInStateData=OFFSET(AgentNames,0,4)</code> and <code>ReleaseCodes=OFFSET(AgentNames,0,5)</code> as shifted <code>AgentNames</code> range.</li> <li>In column <code>A</code> we should obtain the list of names, which should be unique, so select in column <code>A</code> any number of cells which is <strong>NOT less that number of unique names</strong> - for the sample I used <code>A2:A51</code>, and type that formula: <code>=IFERROR(INDEX(AgentNames,SMALL(IF(MATCH(AgentNames,AgentNames,0)=ROW(INDIRECT("1:"&amp;ROWS(AgentNames))),MATCH(AgentNames,AgentNames,0),""),ROW(INDIRECT("1:"&amp;ROWS(AgentNames))))),"")</code> and press <kbd>CTRL</kbd>+<kbd>SHIFT</kbd>+<kbd>ENTER</kbd> instead of usual <kbd>ENTER</kbd> - this will define a <strong>Multicell ARRAY</strong> formula and will result in curly <code>{}</code> brackets around it (but do <strong>NOT</strong> type them manually!).</li> <li><code>B2</code>: <code>=IF(OR($A2="",SUMPRODUCT(--($A2=AgentNames),--(B$1=ReleaseCodes),TIMEVALUE(TimeInStateData))=0),"",SUMPRODUCT(--($A2=AgentNames),--(B$1=ReleaseCodes),TIMEVALUE(TimeInStateData)))</code> - normal formula, which will return empty value for either empty name or zero time.</li> <li>Copy formula from <code>B2</code> to the whole table.</li> </ol> <p>Remarks:</p> <ul> <li>Resulting range for the sum of time values should be formatted as <code>Time</code>.</li> <li>If the list of names should be expanded in the future - <strong>repeat step 3 for the new range</strong>, but do NOT drag the formula down - this will result in <code>You cannot change part of an array</code> error.</li> </ul> <p>Sample file: <a href="https://www.dropbox.com/s/quudyx1v2fup6sh/AgentsTimeSUM.xls" rel="nofollow">https://www.dropbox.com/s/quudyx1v2fup6sh/AgentsTimeSUM.xls</a></p> <p><strong>INITIAL ANSWER:</strong></p> <p>Perhaps that's too simple and obvious, but at a glance I don't understand why you have that line of code:</p> <p><code>cellDate1 = TimeValue("00:00:00")</code></p> <p>right after your <code>SUMIFS</code>: <code>cellDate1 = WorksheetFunction.SumIfs(aa.Range("F:F"), ...</code></p> <p>Try to remove the first one where you assign zeros to <code>cellDate1</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload