Chart's dynamic range formula

Akbarov

Active Member
Joined
Jun 30, 2018
Messages
347
Office Version
  1. 365
Platform
  1. Windows
Hello community,

I use Named Range to make chart range dynamic. But for some reason I am getting wrong result in some columns.

I use same formula: =OFFSET(Sheet1!$N$2,0,0,COUNTA(Sheet1!$N:$N)-1,1)
It works for most of categories, but for 1-2 category it give wrong result as shown in below picture.
It shows 1 row extra. So I get 1 blank bar in my chart.

Any idea why it is acting like these?
Thanks in advance.
 

Attachments

  • dynamicrange.png
    dynamicrange.png
    21.9 KB · Views: 19

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Cell N7 appears blank, but is it really empty or does it actually contain a formula that returns an empty string ( "" ) ?
 
Upvote 0
Solution
Btw, cells getting their values from VBA

VBA Code:
Range("b2").Formula = "=IF(A2<>"""",COUNTIF(Main!$A$3:$A$" & LR & ",Backend!A2)" & ","""")"
  Range("c2").Formula = "=SUMIF(Main!$A$3:$A$" & LR & ",Backend!A2,Main!$G$3:$G$" & LR & ")"
 
          With Sheets("Backend")
  .Range("B2").AutoFill .Range("B2:B" & .Cells(.Rows.Count, "A").End(xlUp).Row)
          End With
         
          With Sheets("Backend")
  .Range("C2").AutoFill .Range("C2:C" & .Cells(.Rows.Count, "A").End(xlUp).Row)
          End With

Last Row of .Cells(.Rows.Count, "A").End(xlUp).Row = 6
It should fill formula down until last empty cell. But it fills 1 row more.
 
Last edited:
Upvote 0
Problem is solved. I just added this line.

VBA Code:
    With Sheets("Backend")
    .Range("B3:C12").ClearContents
    End With
 
Upvote 0

Forum statistics

Threads
1,214,940
Messages
6,122,356
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top