+ Reply to Thread
Results 1 to 2 of 2

Moving up / down in a macro

  1. #1
    Michel Khennafi
    Guest

    Moving up / down in a macro


    Good evening

    I would like to replace the text RANGE("B13").select by a more dynamic way
    of moving the cursor.

    My intent was to tell Excel GO UP ONE ROW... What is the instruction I need
    to put in the macro to say Move up / move down... Go right / go left

    Thanks


    Macro1 Macro
    ' Macro recorded 4/27/2006 by Michel Khennafi
    '

    '
    Application.Goto Reference:="Record_x"
    Selection.EntireRow.Insert
    Sheets("Summary Sheet").Select
    Range("record").Select
    Selection.Copy
    Sheets("Vacation").Select
    Application.Goto Reference:="Record_x"
    Range("B13").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
    _
    False, Transpose:=False
    Application.Goto Reference:="record"
    Range("F38").Select
    Application.CutCopyMode = False
    Selection.ClearContents
    Range("G38").Select
    Selection.ClearContents
    End Sub


  2. #2
    JMB
    Guest

    RE: Moving up / down in a macro

    Look at Offset(row offset, column offset)

    Range("B13").Offset(-1,0) will refer to cell B12
    or, if you just want to select the cell above the active cell

    ActiveCell.Offset(-1,0)

    you could also use
    Range("B13")(0,1)

    in this case B13 is assumed to be cell 1,1 therefore 0,1 refers to the cell
    just above it, 1,2 refers to cell C13 and so on. It's similar to offset, but
    offset would, of course, assume B13 is cell 0,0

    or Cells(13 - 1, 2) would refer to B12.
    or Range("B" & 13 - 1)

    Also, see Chips site for referring to cells within ranges
    http://www.cpearson.com/excel/cells.htm

    "Michel Khennafi" wrote:

    >
    > Good evening
    >
    > I would like to replace the text RANGE("B13").select by a more dynamic way
    > of moving the cursor.
    >
    > My intent was to tell Excel GO UP ONE ROW... What is the instruction I need
    > to put in the macro to say Move up / move down... Go right / go left
    >
    > Thanks
    >
    >
    > Macro1 Macro
    > ' Macro recorded 4/27/2006 by Michel Khennafi
    > '
    >
    > '
    > Application.Goto Reference:="Record_x"
    > Selection.EntireRow.Insert
    > Sheets("Summary Sheet").Select
    > Range("record").Select
    > Selection.Copy
    > Sheets("Vacation").Select
    > Application.Goto Reference:="Record_x"
    > Range("B13").Select
    > Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
    > _
    > False, Transpose:=False
    > Application.Goto Reference:="record"
    > Range("F38").Select
    > Application.CutCopyMode = False
    > Selection.ClearContents
    > Range("G38").Select
    > Selection.ClearContents
    > End Sub
    >
    >


+ 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