+ Reply to Thread
Results 1 to 3 of 3

Target range up until last row

Hybrid View

munkee Target range up until last row 12-17-2009, 06:48 AM
pike Re: Target range up until... 12-17-2009, 07:00 AM
Jack in the UK Re: Target range up until... 12-17-2009, 09:15 AM
  1. #1
    Registered User
    Join Date
    11-22-2009
    Location
    Newcastle,England
    MS-Off Ver
    Excel 2003
    Posts
    78

    Target range up until last row

    Sub conditional ()
    
    Dim cell As Range
    
    
    Set Target = Range("J1:J500")
    
    For Each cell In Target
            Select Case cell.Value
                Case "-3", "3"
                    cell.Offset(0, 1).Interior.ColorIndex = 3
                Case "-2", "2"
                    cell.Offset(0, 1).Interior.ColorIndex = 37
                Case "-1", "1"
                    cell.Offset(0, 1).Interior.ColorIndex = 35
                Case "0"
                    cell.Offset(0, 1).Interior.ColorIndex = 38
                Case Else
                    cell.Offset(0, 1).Interior.ColorIndex = xlNone
            End Select
    
    Next cell
    
    'End conditional formatting
    
    End Sub

    I have the following code which i need to edit.

    At present the code links to the target range j1:j500

    Set Target = Range("J1:J500")
    how can i change this to look for the last row in the sheet so the target is then from J1 -> last row. The problem is that some of the rows in J are blank. However the rows in column C will always have data within up until the last row so I assume the number for the last row can come from there but the target still needs to be column J as i am using offsets to populate column K.
    Last edited by munkee; 12-18-2009 at 04:00 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Target range up until last row

    Hi munkee try
    Range("J1", Range("j" & Rows.Count).End(xlUp))
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Target range up until last row

    Sub myLast_CELL_AND_RANGE_J()
    '// jiuk - Excel up to 2002 (Xp) only
    Set theRANGE = Range("J1", Range("j65536").End(xlUp))
    
    theRANGE.Select
    
    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