Finding columns count of a range

count, excel, vba

Solution

Use

Range(var1a).Columns.Count

Problem

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 ```

Original source