ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting Columns in Dynamic Range (https://www.excelbanter.com/excel-programming/293475-counting-columns-dynamic-range.html)

ExcelMonkey[_102_]

Counting Columns in Dynamic Range
 
I have a Dynamic Named Range "DynamicSeedRow". I know that it span
from D1 to E1 (i.e. two columns)

I am tyring to pass the number of columns to a variable

Dim DataFieldRank As Integer
DataFieldRank = Range("DynamicSeedRow").Columns.Count

I keep getting Error 1004 Method range of Object _Global Failed.

What am I doing wrong?


Thank

--
Message posted from http://www.ExcelForum.com


Frank Kabel

Counting Columns in Dynamic Range
 
Hi your code works if the name is defined for the active workbook. So
you may check (again) your name definition

--
Regards
Frank Kabel
Frankfurt, Germany
"ExcelMonkey " schrieb im
Newsbeitrag ...
I have a Dynamic Named Range "DynamicSeedRow". I know that it spans
from D1 to E1 (i.e. two columns)

I am tyring to pass the number of columns to a variable

Dim DataFieldRank As Integer
DataFieldRank = Range("DynamicSeedRow").Columns.Count

I keep getting Error 1004 Method range of Object _Global Failed.

What am I doing wrong?


Thanks


---
Message posted from http://www.ExcelForum.com/




All times are GMT +1. The time now is 10:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com