+ Reply to Thread
Results 1 to 6 of 6

Select Row 1 through "X" and Delete

  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.

    Please Login or Register  to view this content.
    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.

  2. #2
    Registered User
    Join Date
    08-18-2008
    Location
    Singapore
    Posts
    79
    Hi there,

    What your code does is, it takes everything till the last row, regardless of empty rows in between the data set.

    You want to delete everything that is above the first empty row?

  3. #3
    Registered User
    Join Date
    08-18-2008
    Location
    Singapore
    Posts
    79
    Try this:
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182
    Thank you for your fast reply. The minute I hit post I found an older post (which I had searched for a while) that showed me this:

    Please Login or Register  to view this content.
    Seems to do the trick.

    Now what I am having a hard time doing is selecting cells "S1" : last active column in row 1, using row 2 as my reference. I have tried the following code, but it errors out:
    Please Login or Register  to view this content.
    Ideas?

    Thanks,
    Matt

  5. #5
    Registered User
    Join Date
    08-18-2008
    Location
    Singapore
    Posts
    79
    Why are you using A2 if you're looking for the last used column? To look for the last active column in row 1, which is S1, you could do this:

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182
    Thanks again for the quick reply.

    However, I am not sure I understand how to integrate your code into mine. I need to select cells S1 through the last active column (but there will not be any data in row 1 from S forward. However, row 2 has data.

    Does that make sense??

    Thanks,
    Matt

+ Reply to Thread

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