Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subscript out of Range when using Sheet CODENAME 1

Status
Not open for further replies.

Ebes1099

Technical User
Jul 8, 2009
156
US
I'm not understanding why this line of code gives me a Subscript out of Range error. I'm using the sheet CODENAME because the tab name in Excel gets changed occasionally. If I use the actual tab name in excel it doesn't give me any errors. "MA_BPT_Rng" is a named range in my workbook.

I've tried both of these lines and I get a subscript out of range error.


Code:
numPlans = WorksheetFunction.CountA(Sheets("WCG_Inputs").Range("MA_BPT_Rng"))
numPlans = WorksheetFunction.CountA(ThisWorkbook.Sheets("WCG_Inputs").Range("MA_BPT_Rng"))
 
Hi,

I don't understand your reference to the sheet code name with respect to your code examples.

Assuming that the CodeNames is WCG_Inputs...

Code:
NumPlans = WorksheetFunction.CountA(WCG_Inputs.Range("MA_BPT_Rng"))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top