Results 1 to 13 of 13

find duplicate and clear possible corresponding matching value

Threaded View

SarahPintal find duplicate and clear... 02-14-2010, 08:09 PM
SarahPintal Re: find duplicate and clear... 02-14-2010, 08:26 PM
rylo Re: find duplicate and clear... 02-15-2010, 01:11 AM
SarahPintal Re: find duplicate and clear... 02-15-2010, 01:48 AM
SarahPintal Re: find duplicate and clear... 02-15-2010, 01:49 AM
SarahPintal Re: find duplicate and clear... 02-15-2010, 01:57 AM
rylo Re: find duplicate and clear... 02-15-2010, 06:45 PM
SarahPintal Re: find duplicate and clear... 02-15-2010, 07:34 PM
rylo Re: find duplicate and clear... 02-15-2010, 07:59 PM
SarahPintal Re: find duplicate and clear... 02-15-2010, 08:12 PM
rylo Re: find duplicate and clear... 02-15-2010, 08:29 PM
rylo Re: find duplicate and clear... 02-15-2010, 08:33 PM
SarahPintal Re: find duplicate and clear... 02-15-2010, 08:44 PM
  1. #1
    Forum Contributor
    Join Date
    12-02-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    209

    find duplicate and clear possible corresponding matching value

    Hi guys,

    I cant seem to work out how to reference the drang (named range) and the cell propertly as i keep getting an error.

    Everything in the below code works except the parts below in blue

    details:
    I have in column X lots of names and in column Y (dynamic column\ranges as the users chooses them as per the code) and I want to loop through all names in 'X' and if there are multiple of the same names then for the corresponding 'Y' row entry of each be checked and if they are equal (same $ value) then for one of them of cells in the Y column to be cleared.

    Basically if the same name appears more than once it will most likley have the same $ value and if i do a calculation on the $'s it will be 2,3,10 times the amount it should be, hence the need for this .

    As per the below code I am trying to use 2 for Each loops though I keep getting an error when trying to reference the drng range which has the values in them..




    Private Sub CommandButton1_Click()
      Dim DataSH As Worksheet, rng As Range, iRange As Range, oRange As Range
      Dim drng As Range
      Set DataSH = Sheets("Intergral Dump")
      coloff = ComboBox1.ListIndex + 1
      UserForm1.Hide
      Set iRange = Application.InputBox(Prompt:= _
                    "Please Select the First cell of the INPUT range (WBS list) with your mouse.", _
                        Title:="Specify INPUT Range Cell", Type:=8)
      
      Set oRange = Application.InputBox(Prompt:= _
                    "Please Select the First cell of the OUTPUT range (where you want the values to be appear) with your mouse.", _
                        Title:="Specify OUTPUT Range Cell", Type:=8)
      
      
      With Sheets(iRange.Parent.Name)
        Set rng = .Range(iRange, .Cells(Rows.Count, iRange.Column).End(xlUp))
        rowoff = 0
        For Each ce In rng
          Set FindIT = DataSH.Range("A:A").Find(what:=ce.Value, lookat:=xlPart)
          If Not FindIT Is Nothing Then
            oRange.Offset(rowoff, 0).Value = FindIT.Offset(0, coloff).Value
          Else
            oRange.Offset(rowoff, 0).ClearContents 'clear out any previous data
          End If
          rowoff = rowoff + 1
        Next ce
      
      
      End With
    
    '***********code issue below**********'
    With Sheets(oRange.Parent.Name) 'using the users selected ranges WS.
     Set drng = .Range(oRange, .Cells(Rows.Count, oRange.Column).End(xlUp)) 'as the user selected 1 cell this will use the entire used column as the range.
     For Each mainCell In rng
        For Each testCell In rng
            If (mainCell.Value = testCell.Value) And (drng.mainCell.Value = drng.testCell.Value) Then
     
                testCell.Value = ""
     
            End If
        Next testCell
    Next mainCell
    '***********code issue above**********'
    End With
      Unload Me
      
    End Sub
    
    Private Sub UserForm_Initialize()
      ComboBox1.List = Array("July", "August", "September", "October", "November", "December", "January", "February", "March", "April", "May", "June")
      ComboBox1.ListIndex = 0
    End Sub
    Last edited by SarahPintal; 02-15-2010 at 08:44 PM.

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