title: How to use file path from a cell in VBA?
body: <p>I'm running a VBA script in order to count number of rows in each file in a selected folder and then to display it in an active Workbook.</p>
  
  <pre><code> Option Explicit
  Sub CountRows()
      Dim wbSource As Workbook, wbDest As Workbook
      Dim wsSource As Worksheet, wsDest As Worksheet
      Dim strFolder As String, strFile As String
      Dim lngNextRow As Long, lngRowCount As Long
  
      Application.ScreenUpdating = False
  
      Set wbDest = ActiveWorkbook
      Set wsDest = wbDest.ActiveSheet
  
      strFolder = Dir(Range("C7").Value)
      strFile = Dir(strFolder &amp; "*.xlsx")
      lngNextRow = 11
      Do While Len(strFile) &gt; 0
          Set wbSource = Workbooks.Open(Filename:=strFolder &amp; strFile)
          Set wsSource = wbSource.Worksheets(1)
          lngRowCount = wsSource.UsedRange.Rows.Count
          wsDest.Cells(lngNextRow, "F").Value = lngRowCount
          wbSource.Close savechanges:=False
          lngNextRow = lngNextRow + 1
          strFile = Dir
      Loop
  
      Application.ScreenUpdating = True
  
  End Sub
  </code></pre>
  
  <p>Chooing a folder, I would like to use the directory that is inserted in an active WorkBook cell "C7" instead of writing a directory in a script.
  I tried to substitute:</p>
  
  <pre><code>strFolder = "C:\Users\user\Desktop\"
  </code></pre>
  
  <p>with</p>
  
  <pre><code> strFolder = Dir(Range("C7").Value)
  </code></pre>
  
  <p>but it does not work. Maybe someone has any ideas? Thanks!</p>