Almost all of the work in VBA happens inside of macros. You can declare variables outside of macros (although this changes the variable's scope compared to declaring it inside a macro) and specify some compiler options but that's about it.
This is OK:
Option Explicit
' Declaration
Dim c As Collection
Sub foo()
Set c = New Collection
c.Add "hello", "world"
MsgBox c.Count
End Sub
whereas this will generate a compile error - "Invalid outside procedure":
Option Explicit
' Declaration
Dim c As Collection
' This causes an error
Set c = New Collection
Sub foo()
c.Add "hello", "world"
MsgBox c.Count
End Sub
If you use implicit creation with your variable declaration (Dim x As New y) then that works outside of a macro. Not all objects can be created that way though. This code works:
Option Explicit
' Declaration with implicit creation
Dim c As New Collection
Sub foo()
c.Add "hello", "world"
MsgBox c.Count
End Sub
whereas this code doesn't work (you'll get error 429 - ActiveX component can't create object):
Option Explicit
' Declaration with implicit creation
Dim w As New Workbook
Sub foo()
MsgBox w.FullName
End Sub