+ Reply to Thread
Results 1 to 7 of 7

Range Select + Delete Blanks

Hybrid View

  1. #1
    Forum Contributor pr4t3ek's Avatar
    Join Date
    10-13-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    2003 & 2007, 2010
    Posts
    483

    Range Select + Delete Blanks

    i have the following code:
    Sub DeleteID14CPMBlank()
        Range("L65518:O65518").Select
        Range(Selection, Selection.End(xlUp)).Select
        Selection.SpecialCells(xlCellTypeBlanks).Select
        Selection.Delete Shift:=xlUp
    End Sub
    i would like to somehow amend the line
    Range(Selection, Selection.End(xlUp)).Select
    and make it go all the way up but then go down one row ... if that makes sense... (without selecting the cell)

    i've tried
    Range(Selection, Selection.End(xlUp)-1).Select
    but that doesnt work
    --
    Regards
    PD

    ----- Don't Forget -----

    1. Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks

    2. Thank those who have helped you by Clicking the scales above each post.

    3. Please mark your post [SOLVED] if it has been answered satisfactorily.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello PD,

    When you say all the way up, do mean to row 1 or the first empty row in the range?

    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor pr4t3ek's Avatar
    Join Date
    10-13-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    2003 & 2007, 2010
    Posts
    483
    empty row in the range

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello PD,

    One more question. Which column will always be the longest or do they all vary?

    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor pr4t3ek's Avatar
    Join Date
    10-13-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    2003 & 2007, 2010
    Posts
    483
    they can vary.
    column L & O will always having something(a value) in there though..

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello PD,

    This code uses column "L" to determine the last row.
        Set Rng = Range("L65518:O65518")
        LastRow = Rng.Cells(Rng.Rows.Count, 1).End(xlUp).Row
    Sincerely,
    Leith Ross

  7. #7
    Forum Contributor pr4t3ek's Avatar
    Join Date
    10-13-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    2003 & 2007, 2010
    Posts
    483
    so how do i use that in the context of
       Range("L65518:O65518").Select
        Range(Selection, Selection.End(xlUp)).Select
        Selection.SpecialCells(xlCellTypeBlanks).Select
        Selection.Delete Shift:=xlUp
    where i want those rows to be deleted (because they are blank and do not hold any data in them)

+ 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