VBA Property not equalled
Just a quick question on VBA. I know it's basic but it will clean the spiders nest in my brain
A property is almost always being set equal to something, or perhaps the value of a property is being assigned to something else. Is there any occasion where you do not see this happening? I am scouring my VBA books but i cannot actually find any situation like this.
Property being set equal:
ActiveCell.Interior.ColorIndex = Range(“A1”).Interior.ColorIndex Cells(FinalRow + 1, 1).Value = “Total”
thanks for watching my question
Properties of VBA are always set either one of two ways (ignoring "Setting" Objects for now although essentially they are the same as the first type below).
You can set a constant, in the form of a string or value. This is a fixed constant that will always be static no matter how you run the code (ie Activecell.Value = "Total"
You can assign a variable, which will change depending on how you run the code or the contents of a certain cell/value (ie. Activecell.Value=Range ("A1").Value, as A1's value could be changed by anything.
For the sake of completeness, Setting an Object using Dim x As Object: Set x =CreateObject ("...") ... Set x = Nothing are all fixed and therefore constant. Obviously this could then be used to reference a filepath generated by a variable, but that initial set is fixed (this is why I did not use the get and set terminology as mentioned earlier).
If you think about it, almost every problem is only ever made up of constants and variables.