简体   繁体   中英

Finding columns count of a range

Below is some Excel VBA code that is supposed to print the column count of the range that is specified in the string. I am getting an error in the Debug.Print section. What am I doing wrong?

Dim val1a As String
val1a = "A1:D1"

Dim Rng1 As Range

Debug.Print Rng1(var1a).Columns.Count  ' error here

使用

Range(var1a).Columns.Count

The mistake you did was,

you declared 'val1a' but calling 'var1a'.

correct the typo and you'll be able to get that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM