Consulting

Results 1 to 5 of 5

Thread: Moving contents of cell down one cell

  1. #1

    Moving contents of cell down one cell

    Hi I have tried all I know so here is the problem I would like to slove.
    Cell J27 is the result of a loop I have going. I also have a timer going also.
    Cell J27 has a new stock symbol appearing every five seconds. I would like
    the old stock symbol to move down one cell to J28. When the next stock
    symbol appears in J27 the old one will move to J29 etc until the loop is finished. Can I use Excel formatting or will I need to use a macro?
    Thanks for any help with this.
    Max

  2. #2
    VBAX Regular
    Joined
    Feb 2011
    Posts
    13
    Location
    Quote Originally Posted by Tenspeed39355
    Hi I have tried all I know so here is the problem I would like to slove.
    Cell J27 is the result of a loop I have going. I also have a timer going also.
    Cell J27 has a new stock symbol appearing every five seconds. I would like
    the old stock symbol to move down one cell to J28. When the next stock
    symbol appears in J27 the old one will move to J29 etc until the loop is finished. Can I use Excel formatting or will I need to use a macro?
    Thanks for any help with this.
    Max
    What sort of loop are you using?

    If you are using a VB loop of some sort to get the refreshed data, you could put the following code in the loop before the next data refresh.

    Range("J28").Select
    Selection.Insert Shift:=xlDown
    ActiveCell.Value = Range("J27").Value

    That will push the current values from J28 down, down one cell and put the value of J27 into J28 before J27 gets updated. Just be carefull though, a long enough loop would push the data off the end of the sheet...

    Chris

  3. #3
    Chris This is what I am using. I how it makes sense to you.

    [VBA]Public Sub ProcessData()
    x = 1
    While ActiveSheet.Range("a" & x).Formula <> ""
    ActiveSheet.Range("d1").Formula = ActiveSheet.Range("a" & x).Formula
    ltime = Timer()
    While Timer() - ltime < 2
    DoEvents
    Wend
    x = x + 1
    Wend
    End Sub
    [/VBA]

    The following puts the symbol from D1 in J27



    =IF((AND(C27="pass",D27="pass",E27="pass",F27="pass",G27="pass",H27="pass", I27="pass")),D1,"")



  4. #4
    VBAX Regular
    Joined
    Feb 2011
    Posts
    13
    Location
    Try this.

    [vba]Public Sub ProcessData()
    x = 1
    While ActiveSheet.Range("a" & x).Formula <> ""
    Range("j28").Insert xlDown
    Range("j28").Value = Range("j27").Value
    ActiveSheet.Range("d1").Formula = ActiveSheet.Range("a" & x).Formula
    ltime = Timer()
    While Timer() - ltime < 2
    DoEvents
    Wend
    x = x + 1
    Wend
    End Sub
    [/vba]
    Good luck,

    Chris

  5. #5
    Chris Thanks That works great. Now all I have to do is start the macro
    and sit back and watch it go to work. Before I had to copy cell J27 to a
    hard copy so I had to set the timer to 5 seconds which took some time to
    run thru 600 symbols. I have the timer set to one (1) second. Again thanks
    I will rate this thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •