Vba copy data every 5 minutes

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
471
Office Version
  1. 365
Platform
  1. Windows
Hi would anyone have a vba that would copy data from cell F5 to F16 to H5 to H16 every 5 minutes and paste as values.
so data in F5 would copy to H5, F6 to H6 and so on,
Need it to run on 5 sheets
sheets are named 1,2,3,4,5
Thanks
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi, perhaps something like (seems like you edited your post after my answer)

VBA Code:
Sub Test()
Do While True

Application.Wait (Now + TimeValue("00:05:00"))

Dim i As Integer

For i = 1 to 5

With Sheets("Sheet" & i)
     .Range("F16").value = .Range("F5").value
    
     .Range("H16").value = Range("H5").value
End With

Next i

Loop

End Sub
 
Upvote 0
I pasted code in "this workbook" but nothing happens,
do i paste it somewhere else ?
Thanks
 
Upvote 0
Hi,

try

VBA Code:
Private Sub Workbook_Open()

Do While True

Application.Wait (Now + TimeValue("00:05:00"))

Dim i As Integer

For i = 1 to 5

With Sheets("Sheet" & i)
     .Range("F16").value = .Range("F5").value
    
     .Range("H16").value = Range("H5").value
End With

Next i

Loop

End Sub
 
Upvote 0
Hi,

try

VBA Code:
Private Sub Workbook_Open()

Do While True

Application.Wait (Now + TimeValue("00:05:00"))

Dim i As Integer

For i = 1 to 5

With Sheets("Sheet" & i)
     .Range("F16").value = .Range("F5").value
   
     .Range("H16").value = Range("H5").value
End With

Next i

Loop

End Sub
i get run time error 9 with that ,
debug shows "With Sheets("Sheet" & i)" in yellow
 
Upvote 0
Hi,

do you have 5 sheets, named Sheet1, Sheet2, Sheet3, Sheet4 and Sheet5?

VBA Code:
Private Sub Workbook_Open()

Do While True

Application.Wait (Now + TimeValue("00:05:00"))

Dim i As Integer

For i = 1 to 5

With Sheets(i)
     .Range("F16").value = .Range("F5").value
    
     .Range("H16").value = Range("H5").value
End With

Next i

Loop

End Sub
 
Upvote 0
i have 12 sheets, 1st 7 sheets i want to ignore , next 5 sheets are named 1,2,3,4,5 without the word "sheet"
 
Upvote 0
Hi,

you paste it into "this workbook".

You should try it with an empty workbook, where you add values into cells "F5" and "H5" and if you see that it works.

So create a new workbook, create five sheets, named 1,2,3,4 and 5.

And if that works for you,

then you can paste it into your real workbook.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top