title: Trying to get values from Column A using Excel VBA
body: <pre><code>Sub iterateThroughAll()
      ScreenUpdating = False
      Dim wks As Worksheet
      Set wks = ActiveSheet
  
      Dim rowRange As Range
      Dim colRange As Range
  
      Dim LastCol As Long
      Dim LastRow As Long
      LastRow = wks.Cells(wks.Rows.Count, "A").End(xlUp).Row
  
      Set rowRange = wks.Range("A1:A" &amp; LastRow)
  
      'Loop through each row
      For Each rrow In rowRange
          'Find Last column in current row
          LastCol = 1 'wks.Cells(rrow, wks.Columns.Count).End(xlToLeft).Column
          Set colRange = wks.Range(wks.Cells(rrow, 1), wks.Cells(rrow, LastCol)) &lt;-------------- I get a Run-time error 1004 Application defined or object defined error.
          'Loop through all cells in row up to last col
          For Each cell In colRange
              'Do something to each cell
              Debug.Print (cell.Value)
          Next cell
      Next rrow
      ScreenUpdating = True
  End Sub
  </code></pre>
  
  <p>I get an Application-defined or object-defined error. The code looks okay but not sure why its not working here.</p>
  
  <p>I am trying to get all the used cells in Column A</p>