+ Reply to Thread
Results 1 to 5 of 5

removing lines based on a certain criteria

  1. #1
    Registered User
    Join Date
    03-15-2012
    Location
    toronto, canada
    MS-Off Ver
    Excel 2007
    Posts
    3

    removing lines based on a certain criteria

    hey everyone, so i have a long list of addresses listed downwards in a column, each address (which takes 4 rows) is separated by multiple rows, and I need the addresses separated by only one row.

    Basically, at the end I want all the addresses organized by row (so i have a address on 1 row and 4 columns, currently I have it as 4 rows and 1 column). Thats not the hard part because I have a macro that automatically copies and transposes it across rows. However, my macro transposes rows based on a constant amount of rows that I set. If i can remove all the extra rows in between addresses then I can set my macro to transpose every 5 rows so I can get the addresses to go across rather than downwards.

  2. #2
    Forum Contributor
    Join Date
    01-28-2010
    Location
    Riverside, CA
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: removing lines based on a certain criteria

    When creating your macro, if you click "Use Relative Reference". You could have it move the first address to rows, then delete the now empty rows. Set a keyboard shortcut to that macro, and all you would have to do is repeat using the keyboard shortcut until you are done.

    "Use Relative Reference" will ultimately start out where your selected cell is, not a consistent cell. if you post an example I can setup the macro for you.
    Happy Excel'ing!

  3. #3
    Registered User
    Join Date
    03-15-2012
    Location
    toronto, canada
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: removing lines based on a certain criteria

    here is my macro
    PHP Code: 
    Sub test()
    Dim rng As RangeAs IntegerAs Range
    Columns
    ("c:E").delete
    7
    Set rng 
    Range(Range("a2"), Range("a2").End(xlDown))
    Set c Range("a2")
    Do While 
    <> ""
    'MsgBox c.Address

    Range(c, c.Offset(m - 1, 0)).Copy
    Cells(Rows.Count, "c").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
    Set c = c.Offset(m, 0)
    Loop


    End Sub 


    I have addresses set up like these

    11111
    11111
    11111
    11111


    2222
    2222
    2222
    2222
    ....

    and i have around 2000 addresses


    thanks for helping

  4. #4
    Forum Contributor
    Join Date
    01-28-2010
    Location
    Riverside, CA
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: removing lines based on a certain criteria

    Assuming that you already started converting the 4 cell going to to be horizontal and there are empy rows to the next address.

    I'm also assuming the cell look like this, though it doesn't matter what's in the 4 cells.

    123 street
    City
    State
    Zip

    it will convert to this (in separate cells):

    123 street City State Zip

    To start this macro, select the first blank cell under one of your converted addresses.
    Run macro, it will convert one address at a time, just keep running it until you've converted them all.
    PHP Code: 
        Selection.End(xlDown).Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Selection
    .Cut
        Selection
    .End(xlUp).Select
        ActiveCell
    .Offset(10).Range("A1").Select
        ActiveSheet
    .Paste
        ActiveCell
    .Offset(10).Range("A1").Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Selection
    .Cut
        ActiveCell
    .Offset(-11).Range("A1").Select
        ActiveSheet
    .Paste
        ActiveCell
    .Offset(10).Range("A1").Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Selection
    .Cut
        ActiveCell
    .Offset(-11).Range("A1").Select
        ActiveSheet
    .Paste
        ActiveCell
    .Offset(10).Range("A1").Select
        Selection
    .Cut
        ActiveCell
    .Offset(-11).Range("A1").Select
        ActiveSheet
    .Paste
        Selection
    .End(xlToLeft).Select
        ActiveCell
    .Offset(10).Range("A1").Select 

  5. #5
    Registered User
    Join Date
    03-15-2012
    Location
    toronto, canada
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: removing lines based on a certain criteria

    omg thanks so much, your code worked perfectly

    i really appreciate you helping me out, saved me hours of work

+ 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