0

Below code copies the values from D2 and E2 on Sheet1, to D2 and E2 on Sheet2, adding a new row on Sheet2 every time a row is copied, in every 10 minutes.

Is there any way I can use specific range instead of selecting cell D2 and E2 and save that data on sheet 2 adding a new row?

Sub CopyValues()
Dim RowNo As Long
RowNo = Sheets(2).Cells(Rows.Count, 4).End(xlUp).Row + 1

     Sheets(2).Cells(RowNo, 4) = Sheets(1).Cells(2, 4)
     Sheets(2).Cells(RowNo, 5) = Sheets(1).Cells(2, 5)

Application.OnTime Now + TimeValue("00:03:00"), "CopyValues"

End Sub
L42
  • 19,427
  • 11
  • 44
  • 68
sunil
  • 39
  • 5
  • What you're currently doing is *specific* enough for me. So by *specific*, what do you mean by that? – L42 Jul 25 '18 at 01:12
  • i have the stock volume data which updates in every 3 minutes, i want to copy that data in every 3 minutes to sheet2. and want the data to be paste from next row like (Row + 1), above code works fine but it only copies the data for 2 cells, i want a Range like ("D1:H10"), a complete range with multiple values – sunil Jul 25 '18 at 01:21
  • What you basically need is building a dynamic range. Here's one post which will help you do that - *[finding the last row](https://stackoverflow.com/questions/11169445/error-in-finding-last-used-cell-in-vba)*. Once you build your range, you can then incorporate it to your code. – L42 Jul 25 '18 at 01:25
  • Sorry but Dynamic Ranges may not work as sheet1 range is fixed, just the values are getting updated. In simple words, I just want to copy sheet1 values in interval and paste them in sheet2 – sunil Jul 25 '18 at 14:15

0 Answers0