Results 1 to 6 of 6

Select Row 1 through "X" and Delete

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182

    Select Row 1 through "X" and Delete

    Hello Everyone,

    I have a pretty basic question. I thought I had this mastered, guess not.

    Basically, a program I have has hard coded Rows 1:50 to delete. Problem is that depending on the variable selection in the data set, there could be more than 50 rows that need deleting. Thankfully, there is a BLANK row before the data set begins.

    I have been using the following code, but it selects rows all the way to the bottom of the data set 1300 rows or so.

    Sub DeleteData()
        
        Dim LastRow As Long
        Dim LastCol As Long
      
        
        LastRow = Range("A" & Rows.Count).End(xlUp).Row
        ActiveSheet.UsedRange.Select
    
    ActiveSheet.Rows("1:" & LastRow).Delete
    Selection.Delete Shift:=xlUp
    
    End Sub
    I have all reference values in colum "A", I just don't understand why this code doesn't select row 1:50 only, since A51 is blank....

    Please help. I have attached a (reduced data set) file with the information for you to see what I mean.

    Many thanks,
    Matt
    Attached Files Attached Files
    Last edited by VBA Noob; 11-21-2008 at 03:27 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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