+ Reply to Thread
Results 1 to 6 of 6

Range notation with LastRow

  1. #1
    Forum Contributor
    Join Date
    02-27-2020
    Location
    Rotterdam, The Netherlands
    MS-Off Ver
    2013
    Posts
    425

    Range notation with LastRow

    Hi,

    My macro searches for the lastrow in a usedrange and should change the cell properties of the cells in the last row of columns H and I. How do i write the range? Range("H" & LastRow: "I" & LastRow) won't work.

  2. #2
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: Range notation with LastRow

    MaartenRo,

    Why not use Cells? Define "f" as Last row and

    .range(.cells(f,8),.cells(f,9)) .(do whatever you want)

    Ochimus

  3. #3
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Range notation with LastRow

    I like to use Cells when I have individual row and column values rather than concatenating them into the Range object... although if you prefer to stick with Range, you would do the same thing I show below (the Resize property)...

    Cells(LastRow, "H").Resize(1, 2)

    which will be the range consisting of Columns H and I on the row contained in the LastRow variable.
    Last edited by Rick Rothstein; 01-20-2021 at 10:24 PM.

  4. #4
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Range notation with LastRow

    You sure that should be .Resize(0, 2)?

  5. #5
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Range notation with LastRow

    If the worksheet's UsedRange should determine the last row, then

    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Range notation with LastRow

    Quote Originally Posted by hrlngrv View Post
    You sure that should be .Resize(0, 2)?
    Changed... thanks for catching that.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Range A1 to lastrow and last column
    By joepFIMBLE in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-06-2020, 01:27 PM
  2. Pasting Data using LastRow Range
    By DAN0127 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-29-2016, 05:15 PM
  3. R1C1 lastRow not lastRow when data combined
    By Spyderwoman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-28-2016, 05:20 PM
  4. [SOLVED] Using range with lastrow
    By luizmachado in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-22-2016, 06:04 PM
  5. [SOLVED] LastRow - for next loops longer than lastrow?
    By flabb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-07-2016, 12:39 PM
  6. [SOLVED] BorderAround for Range (lastRow)
    By Quasis in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-06-2015, 03:01 PM
  7. [SOLVED] Changing range in VBA to lastrow
    By BlakeSkate in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-07-2015, 05:01 PM

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