Results 1 to 9 of 9

excel macro - move from cell to cell

This is a discussion on excel macro - move from cell to cell within the Excel Questions forums, part of the Question Forums category; what is the script that tells the curser in an excel spreadsheet to move from cell b1 to cell d20?...

  1. #1
    New Member
    Join Date
    Jan 2005
    Posts
    6

    Default excel macro - move from cell to cell

    what is the script that tells the curser in an excel spreadsheet to move from cell b1 to cell d20?

  2. #2
    Board Regular a7n9's Avatar
    Join Date
    Sep 2004
    Location
    WV, USA
    Posts
    696

    Default Re: excel macro - move from cell to cell

    Select.Range("D20")
    If you've exhausted all the possibilities, remember this; you haven't!
    <a href = "http://www.nandeshwar.info">My home page</a> My Excel/VBA Blog

  3. #3
    New Member
    Join Date
    Jan 2005
    Posts
    6

    Default Re: excel macro - move from cell to cell

    thanks for the help...but i do not think i articulated the question.

    background....in the past i have used the "old" excel macro language. i had loops which counted the number of "passes" then let me use the "counted loops" and goto a cell that was the number of counts from the original cursor position.

    example

    if the original cursor position was in cell a1 and the number of "passes" were 12...then i would "move the cursor" to cell a13.

    using the vba script...how can i command the macro to effectively move the cusrsor to 12 positions (up or down or left or right) based on the loop.

  4. #4
    Board Regular a7n9's Avatar
    Join Date
    Sep 2004
    Location
    WV, USA
    Posts
    696

    Default Re: excel macro - move from cell to cell

    I don't think I'm very clear on what you want and also I do not know the old macro language. But if you want to move the selection from one cell to another cell based on the loop you can say
    Code:
    Select.Range("A" & i)
    where i is your loop variable
    If you've exhausted all the possibilities, remember this; you haven't!
    <a href = "http://www.nandeshwar.info">My home page</a> My Excel/VBA Blog

  5. #5
    New Member
    Join Date
    Jan 2005
    Posts
    6

    Default Re: excel macro - move from cell to cell

    let me restate an even more simple question (which will answer my question)...

    if the cursor (in the spreadsheet) is in a1...and i want the cursor to move 6 cells to the right....what would be the appropriate script using vba?

  6. #6
    Board Regular a7n9's Avatar
    Join Date
    Sep 2004
    Location
    WV, USA
    Posts
    696

    Default Re: excel macro - move from cell to cell

    But what I said is VBA.
    If you've exhausted all the possibilities, remember this; you haven't!
    <a href = "http://www.nandeshwar.info">My home page</a> My Excel/VBA Blog

  7. #7
    New Member
    Join Date
    Jan 2005
    Posts
    6

    Default Re: excel macro - move from cell to cell

    i understand your reply was in vba...but i do not understand how to write a script (using the example of cursor on a1 i want the cursor to move to the right by 6 cells (to a7)....

    sorry if i am being thick

  8. #8
    Board Regular a7n9's Avatar
    Join Date
    Sep 2004
    Location
    WV, USA
    Posts
    696

    Default Re: excel macro - move from cell to cell

    Ohh..
    ok. Now I understand. here you go.
    This is the code you should use:
    Code:
    Sub movecell()
    i = 10
    ActiveCell.Offset(rowOffset:=0, columnOffset:="" & i).Activate
    End Sub
    Here are the instructions where to type the code:
    1. Open the VBE with Alt-F11.
    2. Open the Project Explorer with control-R (it might already be open, that's OK.)
    3. Select the file you're working on in that window by clicking it.
    4. Select Insert, Module from the drop down menus.
    5. Open the Code window by pressing F7. This, too, might be open already.
    6. Copy Paste/Write the code.
    8. Run the code by pressing F5 from the VBE or from Excel under the Tools, Macro, Macros menu.

    Hope this helps.
    If you've exhausted all the possibilities, remember this; you haven't!
    <a href = "http://www.nandeshwar.info">My home page</a> My Excel/VBA Blog

  9. #9
    New Member
    Join Date
    Jan 2005
    Posts
    6

    Default Re: excel macro - move from cell to cell

    thanks

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com