Forum Discussion
VBA Function Problem
- Jan 04, 2024
ValA returns a single value - the value of the top left cell in the range Var.
ValB returns a two-dimensional array containing the values of all cells in the range Var.
I filled the range A1:B3 with numbers
In the Visual Basic Editor:
Debug.Print TypeName(ValA(Range("A1:B3")))
Double
Debug.Print TypeName(ValB(Range("A1:B3")))
Variant()
The () indicate that it is a variant array.
If I use the functions in cell formulas:
As you see, the functions are not equivalent.
CellValueTest returns an error because ValA and ValB return different data types that cannot be compared using =.
ValA returns a single value - the value of the top left cell in the range Var.
ValB returns a two-dimensional array containing the values of all cells in the range Var.
I filled the range A1:B3 with numbers
In the Visual Basic Editor:
Debug.Print TypeName(ValA(Range("A1:B3")))
Double
Debug.Print TypeName(ValB(Range("A1:B3")))
Variant()
The () indicate that it is a variant array.
If I use the functions in cell formulas:
As you see, the functions are not equivalent.
CellValueTest returns an error because ValA and ValB return different data types that cannot be compared using =.