Excel relative command macro Query

Discussion in 'NZ Computing' started by lrolloatparadisedotnetdotnz, May 22, 2005.

  1. I want a macro to move to the first cell in a row from any cell in the
    same row, without recording the cell co-ordinates of the cell from
    which it started.

    That is, I want a relative command, not an absolute command.

    I've tried all the combinations I can think of after I invoked the
    relative button in the Macro record dialog, but I'm still getting
    macro that records the action as starting from a particular cell.

    Using the Select to last cell in row command (Ctrl+Alt+K) I can select
    all the cells in the row and then tint them, but I cannot find a
    relative command to first get to the start of the row.

    I've also searched all the information I can find about navigation in
    Excel, but there doesn't appear to be a relative command corresponding
    with Home in it's absolute sense.

    Any suggestions or solutions ?
    lrolloatparadisedotnetdotnz, May 22, 2005
    #1
    1. Advertising

  2. lrolloatparadisedotnetdotnz

    Impossible Guest

    Ctrl-Up will do it.

    <lrolloatparadisedotnetdotnz> wrote in message
    news:...
    >I want a macro to move to the first cell in a row from any cell in
    >the
    > same row, without recording the cell co-ordinates of the cell from
    > which it started.
    >
    > That is, I want a relative command, not an absolute command.
    >
    > I've tried all the combinations I can think of after I invoked the
    > relative button in the Macro record dialog, but I'm still getting
    > macro that records the action as starting from a particular cell.
    >
    > Using the Select to last cell in row command (Ctrl+Alt+K) I can
    > select
    > all the cells in the row and then tint them, but I cannot find a
    > relative command to first get to the start of the row.
    >
    > I've also searched all the information I can find about navigation
    > in
    > Excel, but there doesn't appear to be a relative command
    > corresponding
    > with Home in it's absolute sense.
    >
    > Any suggestions or solutions ?
    >
    Impossible, May 22, 2005
    #2
    1. Advertising

  3. lrolloatparadisedotnetdotnz

    xray spex Guest

    <lrolloatparadisedotnetdotnz> wrote in message
    news:...
    >I want a macro to move to the first cell in a row from any cell in the
    > same row, without recording the cell co-ordinates of the cell from
    > which it started.
    >
    > That is, I want a relative command, not an absolute command.
    >
    > I've tried all the combinations I can think of after I invoked the
    > relative button in the Macro record dialog, but I'm still getting
    > macro that records the action as starting from a particular cell.
    >
    > Using the Select to last cell in row command (Ctrl+Alt+K) I can select
    > all the cells in the row and then tint them, but I cannot find a
    > relative command to first get to the start of the row.
    >
    > I've also searched all the information I can find about navigation in
    > Excel, but there doesn't appear to be a relative command corresponding
    > with Home in it's absolute sense.
    >
    > Any suggestions or solutions ?
    >


    To move to the left end of a row: Selection.End(xlToLeft).Select
    To move to the right end of a row: Selection.End(xlToRight).Select
    xray spex, May 22, 2005
    #3
  4. Re: Excel relative command macro Query [2]

    I want a macro to go to the first cell in a row from any cell in
    that row, then select to the last occupied cell in the row, and apply
    a tint.

    It was suggested that 'Selection.End(xlToLeft).Select' would take
    the cursor to the first cell in a row.

    When I tested a macro using this command, I get variable results.

    In any of the cells in the first few columns the macro works as
    expected.

    If run in a cell with numbers formatted as text, the macro does
    not go to the first cell in the row, but moves only 2 or 3 cells to
    the left. The next cell to the left is empty in each case.

    Similarly, if the originating cell is 5 0r 6 cells from the left
    end of the row, the macro only enters tint from 1 or 2 cells to the
    left.

    In all cases the cells from the originating cell to the end of
    the row are tinted.

    Any comments or suggestions to ensure that ALL cells in the row
    are tinted ?
    lrolloatparadisedotnetdotnz, May 22, 2005
    #4
  5. lrolloatparadisedotnetdotnz

    Alan Guest

    Re: Excel relative command macro Query [2]

    <lrolloatparadisedotnetdotnz> wrote in message
    news:...
    >
    > I want a macro to go to the first cell in a row from any cell in
    > that row, then select to the last occupied cell in the row, and
    > apply a tint.
    >


    Try this:

    Range(Range("IV" & ActiveCell.Row).End(xlToLeft), _
    Range("A" &ActiveCell.Row)).Interior.ColorIndex = 4


    Replace '4' with whatever colour you like.


    HTH,

    Alan.
    Alan, May 23, 2005
    #5
  6. Re: Excel relative command macro Query [2]

    Alan:

    Tks -- working the way I want it to.
    lrolloatparadisedotnetdotnz, May 23, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ken
    Replies:
    0
    Views:
    410
  2. A.C.
    Replies:
    14
    Views:
    5,904
    Billh
    Nov 12, 2003
  3. Robert11
    Replies:
    0
    Views:
    675
    Robert11
    Dec 9, 2004
  4. lrolloatparadisedotnetdotnz

    Excel Macros - Recording Relative Values ?

    lrolloatparadisedotnetdotnz, May 18, 2005, in forum: NZ Computing
    Replies:
    3
    Views:
    549
    lrolloatparadisedotnetdotnz
    May 18, 2005
  5. lrolloatparadisedotnetdotnz

    Excel Recorded Relative Macro with Search Function

    lrolloatparadisedotnetdotnz, Aug 8, 2007, in forum: NZ Computing
    Replies:
    1
    Views:
    631
Loading...

Share This Page