title: Importing a .cls Macro into Sheet1 when creating a new excel file
body: <p>I'm running a background macro that's based on changes in cells. When I create a new file, I want to make a macro that imports the .csl-file with my background macro to replace "Sheet1" in "Microsoft Excel Objects". I've searched the web, but I can't seem to find a solution that fits my problem. Right now I just copy and paste the code into Sheet1 each time I open a new file, but that's kind of annoying..</p>
  
  <p>The code that I want to <strong>move</strong> is the following :</p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
  
      If Target.Column &gt; 1 Then
  
          If InStr(1, Range(Cells(Target.Row, Target.Column - 1), Cells(Target.Row, Target.Column - 1)).Value, "pos from Rapid") Then
  
              If Not IsEmpty(Target.Value) Then
  
                  Application.DisplayAlerts = False
                  Range(Target.Address).Select
                  Selection.TextToColumns Destination:=ActiveCell.Offset(0, 3).Range("A1"), _
                  DataType:=xlDelimited, TextQualifier:=xlNone, ConsecutiveDelimiter:=False _
                  , Tab:=False, Semicolon:=False, Comma:=True, Space:=False, Other:= _
                  False, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), DecimalSeparator _
                  :=".", TrailingMinusNumbers:=True
                  Application.DisplayAlerts = True
  
              Else
  
                  Range(Cells(Target.Row, Target.Column + 3), Cells(Target.Row, Target.Column + 5)).Value = ""
  
              End If
          End If
      End If
  End Sub
  </code></pre>