The line of code that I don't understand is the following :
Selection.AutoFill Destination:=Sheets("All").Range(ActiveCell.Address & ":DB" & LastRow6), Type:=xlFillDefault 'Autofills the formulas in the column selected to the right until column DB which is the last header of the table
Can someone explain me how "&" works?
The & token in VBA has two meanings, depending on context, i.e. how it's used (or sometimes, accidentally misused).
Type Hint: Long
If it's immediately after an identifier, then it's a type hint if that's not what you intended then you might be looking at an accidentally missing space between the identifier (or literal expression) and the & operator:
MsgBox "Hello, "& Name& "!"
The & here is a type hint for a Long Integer, hence the syntax error.
Actual legal uses would include these:
Dim Value& '<~ As Long
Value& = 42& '<~ Long literal
Debug.Print "Value is a " & TypeName(Value&)
One of these things is not like the others...
They are there for historical/compatibility reasons, it's just how types were declared way back when, in the times before the advent of the As clause. Nowadays we typically prefer readability over terseness.
But that's not why we're here.
String Concatenation Operator
When it's used in an expression, the & symbol is an operator that yields a String value, so its left-hand and right-hand sides (LHS and RHS, respectively) operands get coerced into strings as the expression is evaluated:
Dim Name As String
Name = "World"
MsgBox "Hello, " & Name & "!"
In the above snippet, the Name variable is declared as a String and its value is set to the string literal "World". When the MsgBox function call is being prepared, the arguments get evaluated; the MsgBox function accepts a String first parameter named prompt, so that's what is being evaluated: a string value ("Hello, ") that we concatenate with the RHS operand, a variable that evaluates to "World". Now at this point we have the string value "Hello, World", but then that's the LHS operand of another concatenation, this time with the string value "!". The resulting string is the argument that MsgBox receives into its prompt parameter.
The expression ActiveCell.Address & ":DB" & LastRow6 might evaluate to "A1:DB10341", and that's the string argument that gets passed to a (implicitly late-bound) Worksheet.Range call off a worksheet named "All", (implicitly) from the ActiveWorkbook. The resulting object reference is passed as the Destination parameter of the Range.AutoFill method, as the named argument syntax says (Destination:=...).
Selection.AutoFill Destination:=Sheets("All").Range(ActiveCell.Address & ":DB" & LastRow6), Type:=xlFillDefault
Selection is whatever is currently selected in Excel. It could be a chart, it could be a shape or a button, ...or it could be a Range. The type is Object, which means AutoFill (or any other member call) is late-bound and there's no IntelliSense when you type out or edit the argument list, either. Declare and use a Range variable instead - it's an object reference, so we use the Set keyword to assign:
Dim Sheet As Worksheet
Set Sheet = ActiveWorkbook.Worksheets("All")
Dim Destination As Range
Set Destination = Sheet.Range(ActiveCell.Address & ":DB" & LastRow6)
Dim Target As Range
Set Target = ActiveSheet.Range("B3:B" & LastRow6) 'sure that's the right sheet?
Target.AutoFill Destination, Type:=xlTypeDefault 'you get parameter IntelliSense here
So that's it: the line is a member call to Range.AutoFill with its arguments. By pulling complex argument expressions into a local variable like this, readability is improved, and everything is early-bound and compile-time checked, so no typo can come throw a run-time error 438 anymore (even more so with Option Explicit at the top of every module)!