Query refresh is altering COUNTIFS range

eclpbarney

New Member
Joined
Jul 23, 2009
Messages
1
I have built a dashboard sheet that references information on other sheets that are updated by refreshing queries against TFS.

At times (but not always), my dashboard cells will bang out to #VALUE! because my formula

=COUNTIFS('Sheet2'!$A$3:$A$5000,$B4,'Sheet2'!$K$3:$K$5000,F$3)

becomes

=COUNTIFS('Sheet2'!$A$3:$A$5000,$B4,'Sheet2'!$K$3:$K$5001,F$3)

it tends to be off by 1, but sometimes more. but it's always criteria range 2 that changes
 

pbornemeier

Well-known Member
Joined
May 24, 2005
Messages
3,709
Perhaps your query RefreshStyle is set to insert rows, rather than overwrite them and the in-cell formula adapts to the moved last row.

RefreshStyle Property

Returns or sets the way rows on the specified worksheet are added or deleted to accommodate the number of rows in a recordset returned by a query. Read/write XlCellInsertionMode.
<table><tbody><tr><td>XlCellInsertionMode can be one of these XlCellInsertionMode constants.</td></tr><tr><td>xlInsertDeleteCells. Partial rows are inserted or deleted to match the exact number of rows required for the new recordset.</td></tr><tr><td>xlOverwriteCells. No new cells or rows are added to the worksheet. Data in surrounding cells is overwritten to accommodate any overflow.</td></tr><tr><td>xlInsertEntireRows. Entire rows are inserted, if necessary, to accommodate any overflow. No cells or rows are deleted from the worksheet.</td></tr></tbody></table>
 
Last edited by a moderator:

Forum statistics

Threads
1,081,530
Messages
5,359,349
Members
400,524
Latest member
Excelbat

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top