title: AUTOFILL IN EXCEL MACRO
body: <p>I am trying to use macro recorder in Excel to record a macro to fill down a column of cells, however because the fill down each time is a different number of cells it either fills down to short or too long and this seems to be because the macro identifies the cell range and its fixed.</p>
  
  <p>What I need is to auto populate or auto fill down from:</p>
  
  <pre><code>ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[1],"" "",RC[2])"
  Range("C1").Select
  Selection.AutoFill Destination:=ActiveCell.Range("A1:A261")
  ActiveCell.Range("A1:A261").Select
  </code></pre>
  
  <p>Since file is not always 261? How can I place a command to choose/autofill the last column?</p>
  
  <blockquote>
    <p>Blockquote</p>
  </blockquote>
  
  <pre><code>Sub WMEHOT_Cleaner()
  '
  ' WMEHOT_Cleaner Macro
  '
  
  '
      Columns("A:A").Select
      Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
      Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
      Columns("L:L").Select
      Selection.Cut
      Columns("B:B").Select
      ActiveSheet.Paste
      Columns("C:C").Select
      Selection.Cut
      Range("O1").Select
      ActiveSheet.Paste
      Range("C1").Select
      ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[1],"" "",RC[2])"
      Range("C1").Select
      Selection.AutoFill Destination:=ActiveCell.Range("A1:A261")
      ActiveCell.Range("A1:A261").Select
      Range("C1").Select
      Range(Selection, Selection.End(xlDown)).Select
      Selection.Copy
      Selection.End(xlUp).Select
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
          :=False, Transpose:=False
      Application.CutCopyMode = False
      Columns("D:E").Select
      Selection.ClearContents
      Range("D1").Select
      ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[2],"" "",RC[6])"
      Range("D1").Select
      ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[5],""_"",RC[6])"
      Range("D1").Select
      Selection.AutoFill Destination:=ActiveCell.Range("A1:A261")
      ActiveCell.Range("A1:A261").Select
      ActiveCell.Select
      Range(Selection, Selection.End(xlDown)).Select
      Selection.Copy
      Selection.End(xlUp).Select
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
          :=False, Transpose:=False
      Application.CutCopyMode = False
      Columns("I:J").Select
      Selection.ClearContents
      Columns("O:O").Select
      Selection.Cut
      Columns("E:E").Select
      ActiveSheet.Paste
      Columns("F:F").Select
      Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
      Columns("L:L").Select
      Selection.Cut
      Columns("J:J").Select
      ActiveSheet.Paste
      Range("J1").Select
      Selection.Copy
      Range("L1").Select
      ActiveSheet.Paste
      Application.CutCopyMode = False
      Range("A1").Select
      ActiveCell.FormulaR1C1 = "=""WMEOnline_""&amp;RC[9]"
      Range("A1").Select
      Selection.AutoFill Destination:=ActiveCell.Range("A1:A261")
      ActiveCell.Range("A1:A261").Select
      ActiveCell.Select
      Range(Selection, Selection.End(xlDown)).Select
      Selection.Copy
      Selection.End(xlUp).Select
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
          :=False, Transpose:=False
      Application.CutCopyMode = False
      ActiveCell.Offset(2, 0).Range("A1").Select
      Range("O5").Select
  
  
  
  
          Cells.Select
      Range("A1").Activate
      Selection.Copy
      Workbooks.Add
      ActiveSheet.Paste
  
      msgclean = MsgBox("Cleaning and Sorting Complete!!" &amp; vbNewLine &amp; "File Ready for LMS." &amp; vbNewLine &amp; "Please SAVE this file as CSV Format", vbInformation + vbOKOnly, "WME HOT Cleaner Template")
  
  
  End Sub
  </code></pre>