Sheet name not showing in formula

288enzo

Well-known Member
Joined
Feb 8, 2009
Messages
712
Office Version
  1. 2016
Platform
  1. Windows
Good morning,

Will someone please explain why my formula isn't including the name of the sheet?

VBA Code:
    Dim CRange As Variant
    Set CRange = Sheets("KPI Data - MY22 ONLY").Range("C5:C" & Sheets("KPI Data - MY22 ONLY").Range("A" & Rows.Count).End(xlUp).Row)
    
    Range("G97") = "=countifs(" & CRange.Address & ",C97," & CRange.Offset(0, 19).Address & ",""Yes"")"

The output is - =COUNTIFS($C$5:$C$3407,C97,$V$5:$V$3407,"Yes")

I'm trying to achieve - =COUNTIFS('KPI Data - MY22 ONLY'!$C$5:$C$3407,C97,'KPI Data - MY22 ONLY'!$V$5:$V$3407,"Yes")

Thank you
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I came up with the below, but I'm sure there is a better way?

VBA Code:
    Range("G97") = "=countifs('KPI Data - MY22 ONLY'!" & CRange.Address & ",C97,'KPI Data - MY22 ONLY'!" & CRange.Offset(0, 19).Address & ",""Yes"")"
 
Upvote 0
Try it like
VBA Code:
    Range("G97") = "=countifs(" & CRange.Address(external:=True) & ",C97," & CRange.Offset(0, 19).Address(external:=True) & ",""Yes"")"
 
Upvote 0
Solution
Try it like
VBA Code:
    Range("G97") = "=countifs(" & CRange.Address(external:=True) & ",C97," & CRange.Offset(0, 19).Address(external:=True) & ",""Yes"")"
Something new learned again, thank you as always Fluff.

VBA Code:
(external:=True)
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,203,506
Messages
6,055,807
Members
444,826
Latest member
aggerdanny

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