Results 1 to 9 of 9

How to control of repeating procedures? (delete duplicates rows)

Threaded View

Luu4466 How to control of repeating... 07-18-2021, 02:13 PM
TMS Re: How to control of... 07-18-2021, 03:24 PM
jolivanes Re: How to control of... 07-18-2021, 03:46 PM
Luu4466 Re: How to control of... 07-18-2021, 04:36 PM
TMS Re: How to control of... 07-18-2021, 04:38 PM
Luu4466 Re: How to control of... 07-18-2021, 04:50 PM
TMS Re: How to control of... 07-18-2021, 05:36 PM
Luu4466 Re: How to control of... 07-19-2021, 09:56 AM
TMS Re: How to control of... 07-19-2021, 11:02 AM
  1. #1
    Forum Contributor
    Join Date
    11-07-2020
    Location
    Paris
    MS-Off Ver
    Microsoft office 365
    Posts
    236

    How to control of repeating procedures? (delete duplicates rows)

    I would like to create a structure for repeated operations by using Do While Loop. The DElDuplicates, which searches for and deletes duplicates rows in a database is a good example to explain the situation. Having sorted the database on a specific 'code' field, the entries in the code column are processed row-by row. If the values of the currentCell and nextCell are the same, the currentCell row is deleted.

    I think my problem is caused by the reference objects. I don't know how to name it in my worksheet.

    Sub DelDuplicates()
    Dim currentCell, nextCell
    Range("database").Sort key1:=Range("code") ----------- error here?
    Set currentCell = Range("code")
    Do While Not IsEmpty(currentCell)
      Set nextCell = currentCell.Offset(1, 0)
      If nextCell.Value = currentCell.Value Then
        currentCell.EntireRow.Delete
      End If
      Set currentCell = nextCell
    Loop
    End Sub
    Capture.PNG
    Attached Files Attached Files
    Last edited by Luu4466; 07-19-2021 at 09:57 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Delete Repeating Groups of Rows
    By jn83666 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-31-2016, 03:07 PM
  2. [SOLVED] VBA Code to have a repeating form control /Active X control (List box) in every row
    By Ehezve in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2013, 08:55 PM
  3. How to Delete Repeating Values in Many Rows?
    By sadrap in forum Excel General
    Replies: 1
    Last Post: 01-06-2013, 12:49 PM
  4. Replies: 1
    Last Post: 11-12-2012, 03:03 PM
  5. Delete repeating heading rows
    By xyz123 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-21-2008, 06:32 AM
  6. delete repeating rows
    By aledger in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-04-2005, 05:06 PM
  7. [SOLVED] Closing form turns off commandbar control procedures??
    By Caro-Kann Defence in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2005, 06:06 PM

Tags for this Thread

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