+ Reply to Thread
Results 1 to 17 of 17

Simple problem with comparison

  1. #1
    Registered User
    Join Date
    05-23-2018
    Location
    Ennis, Texas, United States
    MS-Off Ver
    2016
    Posts
    8

    Simple problem with comparison

    Hi,
    I have a large excel with a couple thousand rows of projects. In column R of each row is the location of each project. I have a list of several acceptable locations, and I need delete any project that either isn't in one of those locations or contains no information in column R.
    How I attempted to do this was:

    Please Login or Register  to view this content.
    However, when I attempted to run it as a test, I would get a message saying "Syntax Error".
    What am I doing wrong?
    Also, if you want extra points to help me out, how would I compact the rows together after all unnecessary rows have been deleted?
    Attached Files Attached Files
    Last edited by claytonmtaylor; 05-24-2018 at 11:05 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Simple problem with comparison

    Welcome to the board.

    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    05-23-2018
    Location
    Ennis, Texas, United States
    MS-Off Ver
    2016
    Posts
    8

    Re: Simple problem with comparison

    Quote Originally Posted by shg View Post
    Welcome to the board.

    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.
    Thanks, but the forum rules don't seem to be in english, could you tell me how to do that, or help me with my initial problem?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Simple problem with comparison

    One way:

    Please Login or Register  to view this content.
    Remember that text comparisons in VBA are case-sensitive by default.
    Last edited by shg; 05-23-2018 at 04:42 PM.

  5. #5
    Registered User
    Join Date
    05-23-2018
    Location
    Ennis, Texas, United States
    MS-Off Ver
    2016
    Posts
    8

    Re: Simple problem with comparison

    This works fine, but I need it to be able to read certain strings and not delete those.
    Last edited by jeffreybrown; 05-23-2018 at 07:13 PM. Reason: Removed full quote!

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Simple problem with comparison

    Please Login or Register  to view this content.
    You need to iterate backward when you're deleting rows.

  7. #7
    Registered User
    Join Date
    05-23-2018
    Location
    Ennis, Texas, United States
    MS-Off Ver
    2016
    Posts
    8

    Re: Simple problem with comparison

    Quote Originally Posted by shg View Post
    You need to iterate backward when you're deleting rows.
    Good point, but how would I make something like this work?
    Please Login or Register  to view this content.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Simple problem with comparison

    How about explaining in words what you're trying to do?

  9. #9
    Registered User
    Join Date
    05-23-2018
    Location
    Ennis, Texas, United States
    MS-Off Ver
    2016
    Posts
    8

    Re: Simple problem with comparison

    I thought I was. I have a very large excel with several thousand rows that each represent a project. Each project has a location (Column R). I need to delete any project that either isn't in West Texas, or isn't marked by location, or has an empty column R.

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Simple problem with comparison

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    HTH
    Regards, Jeff

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Simple problem with comparison

    So did you try the code in post#6?

  12. #12
    Registered User
    Join Date
    05-23-2018
    Location
    Ennis, Texas, United States
    MS-Off Ver
    2016
    Posts
    8

    Re: Simple problem with comparison

    It gives me an error saying "Application-defined or object defined error"

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Simple problem with comparison

    Time for post#10.

  14. #14
    Registered User
    Join Date
    05-23-2018
    Location
    Ennis, Texas, United States
    MS-Off Ver
    2016
    Posts
    8

    Re: Simple problem with comparison

    I've got it. This is the code I used, I was getting hung up because of an infinite loop that I fixed.
    Please Login or Register  to view this content.
    Now I've got to sort the data by date, I'm sure I can figure out how to do that.

  15. #15
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Simple problem with comparison

    Maybe this thread can get you started on the sort you desire

    https://www.excelforum.com/excel-pro...ort-marco.html

    Just remove one of the SortFields if you are sorting by one column

  16. #16
    Registered User
    Join Date
    05-23-2018
    Location
    Ennis, Texas, United States
    MS-Off Ver
    2016
    Posts
    8

    Re: Simple problem with comparison

    Thank you!

  17. #17
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Simple problem with comparison

    You are very welcome. Happy we could help.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Simple Comparison
    By mbranan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-11-2017, 09:12 AM
  2. Replies: 1
    Last Post: 02-10-2014, 02:12 PM
  3. simple date comparison - code review
    By VBA FTW in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-11-2013, 06:33 PM
  4. Comparison problem
    By sippy1969 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-15-2012, 01:20 PM
  5. comparison with simple 'if' formula
    By BigPole in forum Excel General
    Replies: 3
    Last Post: 05-14-2010, 08:44 AM
  6. simple MAX + comparison formula
    By j0e in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-04-2005, 02:25 AM

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