title: VBA Finding Lastrow using Lastcolumn
body: <p>I want to be able to determine the last row of a specific column. However, this column is constantly and consistently changing. Therefore, I use a variable <code>lastcolumn2</code> to determine the column I need to figure out. I then need to auto fill this column once I figure out the last row. My current code is as follows:</p>
  
  <pre><code>Dim lastColumn2 As Long
  lastColumn2 = Worksheets(1).Cells(1, Columns.Count).End(xlToLeft).Column
  
  Dim Lastrow2 As Long
  Lastrow2 = Range(lastColumn2 &amp; Rows.Count).End(xlUp).Row
  
  Cells(2, lastColumn2 - 1).Select
  ActiveCell.FormulaR1C1 = "=IF(AND(RC[-1]&gt;3,isnumber(RC[-1])),10,IF(AND(VLOOKUP(RC[-4],R1C[-11]:R50000C[-6],5,FALSE)=10,RC[-1]&lt;3),""Depart"",0))"
  Selection.AutoFill Destination:=Range(Cells(2, lastColumn2 - 1), Cells(785, lastColumn2 - 1))
  Range(Cells(2,lastcolumn2,).AutoFill Destination:=Range(Cells(2,lastcolumn2):lastcolumn2 &amp; lastRow)
  </code></pre>