+ Reply to Thread
Results 1 to 5 of 5

clear same values in one col for each id

Hybrid View

  1. #1
    Registered User
    Join Date
    09-20-2019
    Location
    lebanon
    MS-Off Ver
    2016
    Posts
    36

    clear same values in one col for each id

    Hi I'm trying to clear same values in one column for the same auction id but it's clear all the same values in one column, and I have more than 11000 data:

    Private Sub clearallunits_Click()
    Application.ScreenUpdating = False
        Dim N As Long, allunits As Long, rlook As Range
        
        N = Cells(Rows.Count, "A").End(xlUp).Row
     
        For allunits = N To 2 Step -1
            Set rlook = Range(Cells(allunits - 1, "D"), Cells(1, 1))
           If Application.WorksheetFunction.CountIf(rlook, Cells(allunits, "D")) > 0 Then
                Cells(allunits, "D").Clear
            End If
        Next allunits
       
        Application.ScreenUpdating = True
    End Sub
    my attachment is (sheet1 my data) and (sheet2 the result that I need) any idea for that?
    Attached Files Attached Files
    Last edited by fatoom91; 12-29-2019 at 08:19 PM.

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,248

    Re: clear same values in one col for each id

    Try ... in the meantime you can have a big coffee ... : )
    Option Explicit
    
    Sub aaa()
        Dim r&: r = 2
        Application.ScreenUpdating = False
        Do Until Trim(Cells(r, "A").Value) = ""
            If Cells(r + 1, "A").Value = Cells(r, "A").Value Then Cells(r + 1, "D").Value = ""
            r = r + 1
        Loop
        Application.ScreenUpdating = True
    End Sub

  3. #3
    Registered User
    Join Date
    09-20-2019
    Location
    lebanon
    MS-Off Ver
    2016
    Posts
    36

    Re: clear same values in one col for each id

    Quote Originally Posted by porucha vevrku View Post
    Try ... in the meantime you can have a big coffee ... : )
    Option Explicit
    
    Sub aaa()
        Dim r&: r = 2
        Application.ScreenUpdating = False
        Do Until Trim(Cells(r, "A").Value) = ""
            If Cells(r + 1, "A").Value = Cells(r, "A").Value Then Cells(r + 1, "D").Value = ""
            r = r + 1
        Loop
        Application.ScreenUpdating = True
    End Sub
    thanks alot!

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: clear same values in one col for each id

    You won't have time for a shot of espresso with this...

    Private Sub clearallunits_Click()
        
        Dim v As Variant, i As Long
        
        v = Range("A1").CurrentRegion.Value
        
        For i = UBound(v, 1) To 2 Step -1
           If v(i, 1) = v(i - 1, 1) Then v(i, 4) = ""
        Next i
        
        Range("D1").Resize(UBound(v, 1)).Value = Application.Index(v, 0, 4)
        
    End Sub
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  5. #5
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,248

    Re: clear same values in one col for each id

    It depends in (on ?) what mug ... : )

+ 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 to clear values
    By Throughstream in forum Excel General
    Replies: 8
    Last Post: 04-25-2017, 09:14 PM
  2. [SOLVED] How to clear two comboboxes that depend on each other values.
    By pietras152 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2013, 08:32 PM
  3. Hyperlink to clear cell values
    By sahar in forum Excel General
    Replies: 0
    Last Post: 12-07-2011, 01:27 PM
  4. Replies: 4
    Last Post: 04-01-2009, 06:15 PM
  5. clear all activeX object values
    By Jivo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2009, 08:17 AM
  6. clear all data values
    By punkiegirl420 in forum Excel General
    Replies: 3
    Last Post: 10-14-2006, 01:46 AM
  7. Clear values
    By Rene' in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-04-2005, 01: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