title: VBA code to get the return value of visible rows
body: <p><a href="https://i.stack.imgur.com/V1PyW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V1PyW.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/PNoOF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PNoOF.png" alt="enter image description here"></a>Referring from my previous question.</p>
  
  <p><a href="https://stackoverflow.com/questions/39426748/vba-code-to-auto-select-previous-10-columns">VBA code to auto select previous 10 columns</a></p>
  
  <p>I am trying to add the return value of visible rows from an other sheet. I tried to modify the code given in that post and I am certainly doing something wrong here as its overwriting values entered from the above line of code.</p>
  
  <pre><code>Sub Update()
      Dim nCols As Long, nOffset As Long, Srce As Range
  
      With Range("A1").CurrentRegion
          With .Offset(, .Columns.Count - 1).Resize(1, 1)
              If .Value &lt; Date Then nOffset = 1
              With .Offset(, nOffset)
                  .Resize(2, 1).Value = Application.Transpose(Array(Date, Application.WorksheetFunction.Subtotal(103, Worksheets("Stock").UsedRange.Columns(1).SpecialCells(XlCellType.xlCellTypeVisible))))
                 nCols = IIf(.Column &gt; 10, 10, 10 - .Column - 1)
                .Offset(, -nCols + 1).Resize(, nCols).Select
               End With
          End With
      End With
  End Sub
  </code></pre>
  
  <p>I tried to add the below line to get the return values of visible rows</p>
  
  <pre><code>.Offset(, .Columns.Count).Resize(3, 1) = Application.Subtotal(103, Sheets("Sharedstocks").Range("A:A"))
  </code></pre>
  
  <p>Please suggest</p>