+ Reply to Thread
Results 1 to 3 of 3

Macro almost works. Does not Delete as desired

Hybrid View

yuenk Macro almost works. Does not... 12-01-2014, 09:46 AM
zbor Re: Macro almost works. Does... 12-01-2014, 09:50 AM
alansidman Re: Macro almost works. Does... 12-01-2014, 09:51 AM
  1. #1
    Forum Contributor
    Join Date
    11-19-2014
    Location
    United States
    MS-Off Ver
    2010
    Posts
    137

    Macro almost works. Does not Delete as desired

    I have a macro that deletes duplicate versions of a work number. The macro runs the way I need it to but when it goes to delete the information it doesnt delete the data in columns A & B.

    The file I'm working with
    Test Run pt 4.xlsm


    Sub keep_highest()
    
    Dim k As Object, c, al As Long
    Set k = CreateObject("Scripting.dictionary")
    c = Sheets("sheet1").Cells(1).CurrentRegion
    For al = 2 To UBound(c)
        If c(al, 8) > k(c(al, 3)) Then k(c(al, 3)) = c(al, 8)
    Next al
    For al = UBound(c) To 2 Step -1
        If c(al, 8) <> k(c(al, 3)) Then Cells(al, 3).Resize(, UBound(c, 2)).Delete xlUp
    Next al
    
    End Sub

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,040

    Re: Macro almost works. Does not Delete as desired

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Never use Merged Cells in Excel

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,713

    Re: Macro almost works. Does not Delete as desired

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum:

    i have changed the title to be more descriptive. Please read the rules and adhere to them in the future.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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. vba help to delete the column till values met desired header
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-14-2014, 07:32 AM
  2. [SOLVED] Delete all cell content in column except for desired string
    By SammieRae in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-23-2013, 06:22 PM
  3. Help with macro to delete text and leave time in all desired cells
    By ncguy131 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-04-2013, 01:23 PM
  4. Replies: 2
    Last Post: 11-08-2012, 05:10 PM
  5. [SOLVED] Delete all data (formulas) below a desired row.
    By JMSimms in forum Excel General
    Replies: 2
    Last Post: 05-16-2005, 04:06 PM

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