Hey everyone, just looking for a little bit of help from someone with the knowhow. I've just recently started using VBA, so if this seems pretty straight forward, sorry in advance, but I can't find code that works for me.
I'm using a variable word to tell me the height of water in a tank. I've no problem using the value in excel. What I want to do is have excel look at the height every 5 seconds (located in A1), take a snapshot of the value and copy it into the next cell in column B. So at 'on-time', zero is in B1, 5 seconds later a value is in B2 and so on for roughly 30 minutes.
The code I've come up with works the 5 second delay and the pasting of the value into the appropriate cells, but stops the active cell (A1) from changing at all! Any help would be much appreciated, here's the code I've written:
Sub ctrl()
dim x as integer
for x = 2 to 400
if target = range("A1") Then
if range("A1").value = timevalue("00:0:00") Then
cells(x,2).value = range("A1").value
end if
end if
application.wait now + timevalue("00:00:05")
next x
end sub
I'm using a variable word to tell me the height of water in a tank. I've no problem using the value in excel. What I want to do is have excel look at the height every 5 seconds (located in A1), take a snapshot of the value and copy it into the next cell in column B. So at 'on-time', zero is in B1, 5 seconds later a value is in B2 and so on for roughly 30 minutes.
The code I've come up with works the 5 second delay and the pasting of the value into the appropriate cells, but stops the active cell (A1) from changing at all! Any help would be much appreciated, here's the code I've written:
Sub ctrl()
dim x as integer
for x = 2 to 400
if target = range("A1") Then
if range("A1").value = timevalue("00:0:00") Then
cells(x,2).value = range("A1").value
end if
end if
application.wait now + timevalue("00:00:05")
next x
end sub