Results 1 to 2 of 2

Thread: Excel: sorting a list via VBA

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    Excel: sorting a list via VBA

    I have a dynamic list that can have data added/removed from it by the user. I have got the "adding" part sorted out okay but am having some trouble with the "removing" part. Here is an example of what my list looks like:

    Code:
    Name
    -----
    Tracy
    Bob
    Anna
    Roger
    So the list is not in alphetical order. What I want to do is be able to remove any item from the list e.g. remove "Anna":

    Code:
    Name
    -----
    Tracy
    Bob
    
    Roger
    And then to move all entries below where "Anna" was in order to remove the blank space e.g.

    Code:
    Name
    -----
    Tracy
    Bob
    Roger
    However I do not want to sort the list alphabetically. I want the names to stay in the exact same order.

    Does anyone have any suggestions as to how I can achieve this via a VBA macro?

    Cheers
    -Rob
    http://www.sudsolutions.com

  2. #2
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Excel: sorting a list via VBA

    Are you deleting/adding data from more than 1 column? If not, here is some starter code:
    Code:
    Option Explicit
    
    Sub Macro1()
        
        Dim aRow As Long
        
        aRow = 4
        Cells(aRow, "A").Delete Shift:=xlUp
    
    End Sub
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width