+ Reply to Thread
Results 1 to 3 of 3

Deleting all rows after the last active cell

Hybrid View

  1. #1
    Registered User
    Join Date
    09-17-2003
    Location
    Scotland
    Posts
    59

    Deleting all rows after the last active cell

    I need to download a file on a regular basis and this number of rows in the files varies each time it is downloaded. I am using a macro on column B to carry out the MID function on column A. Once the function has been carried out I then need to copy the formula down all of column B as I don't know what the last active cell will be from one download to the next. The result is that I have thousand of excess rows which I need to delete. Can anyone give me code that will delete all rows from the last active cell onwards.

    Thanks

    Shirley

  2. #2
    Dave Peterson
    Guest

    Re: Deleting all rows after the last active cell

    How about just applying the formula to the rows you want.

    Dim LastRow as long
    with activesheet
    lastrow = .cells(.rows.count,"A").end(xlup).row
    .range("b1:B" & lastrow).formula = "=mid(yourformulahere)"
    end with



    Shirley Munro wrote:
    >
    > I need to download a file on a regular basis and this number of rows in
    > the files varies each time it is downloaded. I am using a macro on
    > column B to carry out the MID function on column A. Once the function
    > has been carried out I then need to copy the formula down all of column
    > B as I don't know what the last active cell will be from one download to
    > the next. The result is that I have thousand of excess rows which I
    > need to delete. Can anyone give me code that will delete all rows from
    > the last active cell onwards.
    >
    > Thanks
    >
    > Shirley
    >
    > --
    > Shirley Munro
    > ------------------------------------------------------------------------
    > Shirley Munro's Profile: http://www.excelforum.com/member.php...nfo&userid=836
    > View this thread: http://www.excelforum.com/showthread...hreadid=469489


    --

    Dave Peterson

  3. #3
    Registered User
    Join Date
    09-17-2003
    Location
    Scotland
    Posts
    59

    Deleting empty rows

    Hi Dave

    Many thanks for your help - your code worked perfectly. The reason I wasn't just applying the formula to the cells I needed was that I wanted it all to run from a macro and now it does.

    Shirley

+ 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