1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Excel macro/vba to delete rows

Discussion in 'Business Applications' started by Gombot, Nov 14, 2008.

Thread Status:
Not open for further replies.
  1. Gombot

    Gombot It's My Birthday! Thread Starter

    Joined:
    Mar 11, 2008
    Messages:
    82
    Hi All,

    I have a spreadsheet containing 30 address blocks that I'm trying to clean up. A sample is attached.

    All of the data is in column A. Each address block is 6 rows, like this:

    Name
    Company Name
    Street Address
    City/State/Zip
    Phone number
    Email Address

    Between each 6 row block is a varying number of additional rows that might or might not contain extraneous information. I want to remove those extra rows leaving only the address blocks.

    I'm thinking about counting the "x" number of rows between email address "@" symbols, and then just deleting X-6 rows. But I'm not sure how to accomplish this.

    Any ideas how this might be accomplished, or any better suggestions to accomplish the goal?
     
  2. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,546
    "might or might not contain extraneous information"

    For Each Cell In Range("A1", Range("A" & Rows.Count).End(xlUp))
    If InStr(Cell, "@") <> 0 Then
    Cells(Cell.Row - 5, 1).Resize(6, 1).Copy Range("B" & Rows.Count).End(xlUp).Offset(1)
    End If
    Next Cell


    If those are real names and addresses, you should remove your file.
     
  3. Gombot

    Gombot It's My Birthday! Thread Starter

    Joined:
    Mar 11, 2008
    Messages:
    82
    Excellent! Thank you Bomb #21
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/769443

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice