Search for columns in a range

Below is the Excel vba code that is trying to print the number of columns of the range specified in a row. I get 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 
+4
source share
2 answers

Using

Range (var1a) .Columns.Count

+8
source

The mistake you made was

you declared 'val1a' but you called 'var1a'.

correct the typo and you can get it.

+1
source

Source: https://habr.com/ru/post/1436897/


All Articles