+ Reply to Thread
Results 1 to 4 of 4

Macro to record keystrokes and not cell addresses

  1. #1
    Brian William Johnston
    Guest

    Macro to record keystrokes and not cell addresses

    I have a multi page spreadsheet, and I would like to have the macro record an
    area that changes its number of rows constantly.

    What I am getting back in the macro is an specific range of cells from the
    table array sheet no matter how many rows it contains, and I use the END DOWN
    to assign the range.

    The lookup value on the main page records as END+DOWN, but seems to not
    carry this feature to the other pages in the workbook.

    Am using winXP with Office 2003.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    You can mimic the end down keystrokes with the End method of the range object

    e.g Range(Cells(1,1),Cells(Cells(65536,1).end(xlup).row,1)).select

    selects all the cells in column 1 from first to last occupied.

    You might also try using Cells(1,1).CurrentRegion to return the range that is equivalent to hitting the control-shift-8 key combination.

  3. #3
    Loomah
    Guest

    Re: Macro to record keystrokes and not cell addresses

    Hi
    There are a number of ways to deal with this

    I'm assuming your data is contiguous and starts in cell A1

    range("a1").currentregion.select - selects all your cells that are
    contiguous to A1

    Range("A1:F" & Cells(1, 1).End(xlDown).Row).Select - selects the range of
    cells from A1 to col F & the equivalent of using END DOWN to find the last
    row from A1, assumes no gaps

    You could do the same thing starting from the bottom if there are gaps in
    column A, ie
    Range("A1:F" & Cells(1, 65536).End(xlup).Row).Select

    And I'm sure I could go on!

    HTH

    "Brian William Johnston" <Brian William Johnston@discussions.microsoft.com>
    wrote in message news:3C19726D-CEC3-4423-BE7F-BE50782F4A61@microsoft.com...
    >I have a multi page spreadsheet, and I would like to have the macro record
    >an
    > area that changes its number of rows constantly.
    >
    > What I am getting back in the macro is an specific range of cells from the
    > table array sheet no matter how many rows it contains, and I use the END
    > DOWN
    > to assign the range.
    >
    > The lookup value on the main page records as END+DOWN, but seems to not
    > carry this feature to the other pages in the workbook.
    >
    > Am using winXP with Office 2003.




  4. #4
    Brian William Johnston
    Guest

    Re: Macro to record keystrokes and not cell addresses

    Loomah,

    Cells are contiguous, however they are on another page.

    The "Range(Selection,Selection.End(xlDown)) .select works fine on the page
    where the macro is being recorded, however it still returns absolute
    addresses on the othe pages in this Excel file.

    Below is example of what the macro returns. I am not sure how to modify the
    code to force the End.Down or End.Left parameters.

    Range("Q2").Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-13],Clients!R1C1:R36174C7,5,FALSE)"
    Range("R2").Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-14],Clients!R1C1:R36174C7,6,FALSE)"
    Range("S2").Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-15],Clients!R2C1:R36174C7,7,FALSE)"
    Range("P2").Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[1],Offset!R2C1:R25C2,2,FALSE)"
    Range("P2:S2").Select
    Selection.Copy
    Range("P3").Select
    Range(Selection, Selection.End(xlDown)).Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Range("P1:S1").Select
    Range(Selection, Selection.End(xlDown)).Select

    As you can see (Selection, Selection.End(xlDown)).Select
    works fine on the main sheet in a multi page file, but when accessing the
    Clients of Offset, this feature is lost.

    Are you aware of any serious tutorials dealing with this subject.

    BWJ


    "Loomah" wrote:

    > Hi
    > There are a number of ways to deal with this
    >
    > I'm assuming your data is contiguous and starts in cell A1
    >
    > range("a1").currentregion.select - selects all your cells that are
    > contiguous to A1
    >
    > Range("A1:F" & Cells(1, 1).End(xlDown).Row).Select - selects the range of
    > cells from A1 to col F & the equivalent of using END DOWN to find the last
    > row from A1, assumes no gaps
    >
    > You could do the same thing starting from the bottom if there are gaps in
    > column A, ie
    > Range("A1:F" & Cells(1, 65536).End(xlup).Row).Select
    >
    > And I'm sure I could go on!
    >
    > HTH
    >
    > "Brian William Johnston" <Brian William Johnston@discussions.microsoft.com>
    > wrote in message news:3C19726D-CEC3-4423-BE7F-BE50782F4A61@microsoft.com...
    > >I have a multi page spreadsheet, and I would like to have the macro record
    > >an
    > > area that changes its number of rows constantly.
    > >
    > > What I am getting back in the macro is an specific range of cells from the
    > > table array sheet no matter how many rows it contains, and I use the END
    > > DOWN
    > > to assign the range.
    > >
    > > The lookup value on the main page records as END+DOWN, but seems to not
    > > carry this feature to the other pages in the workbook.
    > >
    > > Am using winXP with Office 2003.

    >
    >
    >


+ 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