Consulting

Results 1 to 5 of 5

Thread: Making the next cell active

  1. #1

    Making the next cell active

    Can someone help me with this macro? I have a ss with stock symbols in
    Sheet1 A1:A450. Can a macro be written that will make each cell in A1:A450
    active one at a time moving thru the whole list of symbols just like I would take
    the mouse and click on them one at a time.
    Thanks for your time
    Max

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    You could try code like this.

    Dim rng As Range
    Dim c As Range
    Set rng = Worksheets("Sheet1").Range("A1:A450")
    For Each c In rng.Cells
    c.Activate
    Next c
    By the way why do you want to do this, you don't actually need to select/activate cells/ranges to work with them.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Master
    Joined
    Jan 2005
    Location
    Porto Alegre - RS - Brasil
    Posts
    1,219
    Location
    Hi Tenspeed39355,

    as you said you are going to use it with stock simbols I believe you want it to stay at each cell suficient time to read it, so I made this change to Nories code:


    Dim rng As Range
    Dim c As Range
    Set rng = Worksheets("Sheet1").Range("A1:A8")
    For Each c In rng.Cells
    c.Activate
        Application.Wait (Now + TimeValue("0:00:02")) 'This is the time it will remain at each cell
    Next c
    Best Regards,

    Carlos Paleo.

    To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.

    If Debugging is harder than writing a program and your code is as good as you can possibly make
    it, then by definition you're not smart enough to debug it.




    http://www.mugrs.org

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Paleo,
    I believe Max's query is related to this problem
    http://www.vbaexpress.com/forum/showthread.php?t=1799
    MD

  5. #5
    Administrator
    VP-Knowledge Base VBAX Master
    Joined
    Jan 2005
    Location
    Porto Alegre - RS - Brasil
    Posts
    1,219
    Location
    Hi MD,

    gee I didnt know that (he should have put a link to that post here), thanks.
    Best Regards,

    Carlos Paleo.

    To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.

    If Debugging is harder than writing a program and your code is as good as you can possibly make
    it, then by definition you're not smart enough to debug it.




    http://www.mugrs.org

Posting Permissions

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