Thanks Thanks:  0
Likes Likes:  0
Results 1 to 8 of 8

Thread: go back to active cell after running macro

  1. #1
    Board Regular
    Join Date
    Oct 2007
    Location
    Madrid, Spain
    Posts
    254
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default go back to active cell after running macro

    Does anyone know how to automatically go back to the cell I was working on (meaning, the cell I last worked on) before I run a macro?

    thanks

  2. #2
    Board Regular
    Join Date
    Oct 2004
    Posts
    3,482
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: go back to active cell after running macro

    you can try something like this...

    put this at the beginning of your macro
    Code:
    Set rng = ActiveCell
    put this at the end of your macro

    Code:
    Application.Goto rng

  3. #3
    Board Regular
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,699
    Post Thanks / Like
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)

    Default Re: go back to active cell after running macro

    Quote Originally Posted by anxoperez View Post
    Does anyone know how to automatically go back to the cell I was working on (meaning, the cell I last worked on) before I run a macro?

    thanks
    There's usually no need to select other cells/ranges/sheets when making changes to them via code.
    Neil

  4. #4
    Board Regular
    Join Date
    Oct 2007
    Location
    Madrid, Spain
    Posts
    254
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: go back to active cell after running macro

    I thought I could help you with your post number 2600, but I'll have to leave you with 2599. Your explanation worked beautifully.

    thanks

  5. #5
    MrExcel MVP HalfAce's Avatar
    Join Date
    Apr 2003
    Location
    Alaska
    Posts
    9,453
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: go back to active cell after running macro

    anxoperez,
    While Nooch seems to have you back under way, njimack makes a good point.
    Depending on what your code is doing, there's a 99% (+) chance that the active cell never needs to be left in the first place. And, (again, depending on your code) it will run a lot faster/more efficiently if you don't.

  6. #6
    Board Regular
    Join Date
    Oct 2007
    Location
    Madrid, Spain
    Posts
    254
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: go back to active cell after running macro

    Sorry. I am afraid I can't understand what you guys mean.

    Could you explain in further detail?

    thanks

  7. #7
    MrExcel MVP erik.van.geit's Avatar
    Join Date
    Feb 2003
    Location
    Belgium 3272 Testelt
    Posts
    17,832
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: go back to active cell after running macro

    Hi,

    Say you want to change cell A1.
    This is code generated by the macro recorder.
    Code:
        Range("A1").Select
        ActiveCell.FormulaR1C1 = "123"
    instead use
    Code:
        Range("A1") = "123"
    no need to select A1

    useful info
    http://www.tushar-mehta.com/excel/vb...rder/index.htm

    kind regards,
    Erik
    I love Jesus

    email Erik

    founder of DRAFT

    my free Addins
    Table-It download & info
    Formula Translator 04

  8. #8
    Board Regular
    Join Date
    Oct 2007
    Location
    Madrid, Spain
    Posts
    254
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: go back to active cell after running macro

    achso!

    I got it now!

    Great.

    Thanks 2 all of you.

Some videos you may like

User Tag List

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
  •