+ Reply to Thread
Results 1 to 5 of 5

Make macro independent of position

  1. #1
    Registered User
    Join Date
    11-08-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    25

    Make macro independent of position

    Hi,

    I've recorded a macro that copies a formula, pastes the value of that formula into the column to the right of it, copies that, goes to the worksheet to the left, brings up the Goto dialogue box, and writes B"CTRL+V"

    As you can see from the last line in this code, the last part doesn't work. It always goes to row 31, column C.

    How can I change that?

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Easy question on making a macro independent of position

    Hello Call,

    This line of code is responsible for taking you to "C31"...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,977

    Re: Easy question on making a macro independent of position

    I am trying to figure out what you really want to do, and this is how it sounds:

    You have a formula in a cell. You want to paste the result of that formula in the cell immediately to the right. That value is a cell reference. Then you want to go to whatever cell that reference indicates. Is that right?

    Your code suffers from macro recorder bloat. Excel's macro recorder records every step of every action, because it doesn't know what you're going to do next. Try this:

    Please Login or Register  to view this content.
    If you don't really need to copy the value to the cell to the right, and you're only doing that so you could copy the value from there to be able to paste it to a GoTo, then your code collapses to this:

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    11-08-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: Easy question on making a macro independent of position

    Thanks for your replies

    Oh, yes. I'm sorry. Reading my post back now I see I've made myself not clear at all.


    I have two worksheets I'd like to match up the rows of. (Add rows in the shorter list)

    To do that I've set up a 3rd worksheets which compares them. When the comparison returns FALSE, I'd like to get the current row, switch to the relevant worksheet, and go to the relevant row.

    So, I've added a column with =row()... and for the rest see my first post.


    I've tried your code a bit. But I haven't yet gotten it to work. I also need to go to a different worksheet

    Please Login or Register  to view this content.

    ------------------------------------------------------------------------------------
    EDIT1:

    By the way, I am able to compare the two worksheet from a technique someone on this forum taught me a while ago: =INDIRECT("'[Test.xls]Sheet 1'!D"&ROW())

    The third worksheet is basically two columns that reference the two worksheets via this INDIRECT method, and a third column that has =EXACT(A3,B3) (comparing the two). I've now added the =ROW() column.

    The INDIRECT method references the cells I need to jump to. Maybe that can be part of an easy solution?

    --------------------------------------------------------------------------------------
    EDIT2:

    When pasting into the GoTo dialogue box, Excel pastes the value, so I can simplify this faulty code to:

    Please Login or Register  to view this content.
    I've tried using 6StringJazzer's code, but my VBA skills are nonexistent.
    Last edited by Call; 03-18-2011 at 07:10 PM.

  5. #5
    Registered User
    Join Date
    11-08-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: Make macro independent of position

    Anyone any idea?

    I run into this more often: whenever a pop-up is a part of the macro, the result of the pop-up is fixed.

    Normally I then just make two macros: 1 that leads up to the pop-up and a second that continues from there. I'd like to do things differently here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1