+ Reply to Thread
Results 1 to 8 of 8

looping through and deleting rows

  1. #1
    Registered User
    Join Date
    07-28-2009
    Location
    Chicago, Il
    MS-Off Ver
    Excel 2007
    Posts
    67

    looping through and deleting rows

    I have a spreadsheet that has Column A (Name) column B (login information) column C (Date) Column D (Time)
    example:
    john doe Login 9/2/09 10:30am
    John doe coach 9/2/09 12:00pm
    john doe end shift 9/2/09 5:00pm

    the spreadsheet has several names and login information what i need to do is go through the sheet and find login for that day and end shift for that day and delete all other rows for each person on the spread sheet.

    Can this be done first off, i believe i would need to loop through but i cannot come up with a way to look at each name and then delete the other rows
    need some serious help here

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: looping through and deleting rows

    You can loop through the column and delete rows based on the value of column B. Like so:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-28-2009
    Location
    Chicago, Il
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: looping through and deleting rows

    Thanks for the loop but i tried and it did not work, I dont know why, there were no error messages but it just would not delete.. any other ideas

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: looping through and deleting rows

    Code slightly amended and runs fine during testing. I assumed you have a header row you may want to keep so I adjusted to code to not delete row1.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Palmetto; 09-03-2009 at 06:31 PM.

  5. #5
    Registered User
    Join Date
    07-28-2009
    Location
    Chicago, Il
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: looping through and deleting rows

    Ok I think i have something working but it is working the opposite of what I need. I need to keep all rows that have "Login/Not Entered" or "End_Of_Shift" and delete all others but it is deleting all rows with the information above.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: looping through and deleting rows

    Yeah, you reversed the logic when you edited it. Here, I'll switch it back:
    Please Login or Register  to view this content.
    It's smarter to leave in the LCase() stuff since it makes your macro NOT be case sensitive, it would match LOGIN and Login and login and LOGin all equally.

  7. #7
    Registered User
    Join Date
    07-28-2009
    Location
    Chicago, Il
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: looping through and deleting rows

    Thanks it looks like its doing what it needs to do, now all i have to do is create more macros to finish it off, trying them now if I have any problems i know where to get the answers

    Thanks alot
    Last edited by Ricardo9211; 09-03-2009 at 07:22 PM. Reason: Solved

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: looping through and deleting rows

    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].


    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated)

+ 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