Range a = Selection.SpecialCells(xlCellTypeConstants, 23)
This is not a valid VBA, regardless of the data type. You do not declare the type of the variable before the variable name, as it would in C #, and you do not initialize the variable at the declaration point, as it would in VB.NET.
You can do:
Dim a As Range Set a = Selection.SpecialCells(xlCellTypeConstants, 23)
This will keep the range reference in a .
You can also do:
Dim a As Variant a = Selection.SpecialCells(xlCellTypeConstants, 23)
This will save in a 2D array of cell values โโin the range.
Returns a Range object that represents all cells that match the specified type and value.
But it actually returns a byRef object, so I have to use Set.
There are no byte objects in VBA. All objects are byref, and if you want to copy a link to an object, you always use Set . The reason you need Set is the default properties. Each object can have a default property, which is requested when only the name of the object is provided. This creates ambiguity, so you need to tell Set when you need to manipulate the reference to itselt object and omit Set if you want the default property for the object. The default property of Range is Value .
GSerg Jul 26 '13 at 9:25 am 2013-07-26 09:25
source share