honeyoak
04-27-2011, 12:08 PM
Hi all, I am trying to create a macro that makes a visible queue from a dynamically changing cell (all values are integers). I am having a hard time with the logic structure.
for example, to use array notation ( just replace cells with the x's):
lets say that we have the following cells:
x[i,j] = 1
x[i+1,j] = 2
x[i+2,j] = 4
x[i+3,j] = 4
x[i+4,j] = 2
where x[i,j] changes dynamically. lets say that x[i,j] now equals 2 - the x[i+4,j]'s value is dropped ;
x[i,j] = 2
x[i+1,j] = 1
x[i+2,j] = 2
x[i+3,j] = 4
x[i+4,j] = 4
I want this to update every 5 seconds or so. my current code is a bit of a mess b
Sub loops()
Dim c1, c2 As Integer
c1 = 2
c2 = 2
Do While c1 <= 10
If Cells(c1, 1).Value <> Cells(c1 + 1, 1) Then
Cells(c1 + 1, 1).Value = Cells(c1, 1).Value
Cells(c1, 1).Value = Cells(c1 - 1, 1).Value
End If
c1 = c1 + 1
Loop
End Sub
thanks a bunch.
for example, to use array notation ( just replace cells with the x's):
lets say that we have the following cells:
x[i,j] = 1
x[i+1,j] = 2
x[i+2,j] = 4
x[i+3,j] = 4
x[i+4,j] = 2
where x[i,j] changes dynamically. lets say that x[i,j] now equals 2 - the x[i+4,j]'s value is dropped ;
x[i,j] = 2
x[i+1,j] = 1
x[i+2,j] = 2
x[i+3,j] = 4
x[i+4,j] = 4
I want this to update every 5 seconds or so. my current code is a bit of a mess b
Sub loops()
Dim c1, c2 As Integer
c1 = 2
c2 = 2
Do While c1 <= 10
If Cells(c1, 1).Value <> Cells(c1 + 1, 1) Then
Cells(c1 + 1, 1).Value = Cells(c1, 1).Value
Cells(c1, 1).Value = Cells(c1 - 1, 1).Value
End If
c1 = c1 + 1
Loop
End Sub
thanks a bunch.