Somewhere i got messed up with below code. Below is something what i am trying to achieve.
Whenever a user enters new value in any cell of column C:C, vba code must check for only that call value already exists in entire column C:C, if its found, then it must set corresponding column I:I cell value "Multiple". If not found, it must set to "Single".
1) Currently i am looping through entire C:C column which is not correct. I want value for cell in column I:I to be updated for new entries in columns C:C only.
(I have values update 5000 + rows..So looping slows down the process)
2) User may enter multiple cell values in one shot (Like, he copies 10 rows of data from some other database and pastes it directly into Excel sheet upto column H:H).
How to i achieve it..? Please help..Attached is the sample work book and has got code it (Which basically doesn't work).
Private Sub Worksheet_Change(ByVal Target As Range)If Target.Column = 3 Then Dim lastRow As Long Dim matchFoundIndex As Long Dim iCntr As Long Dim Rng As Range Dim cell As Range Set Rng = Worksheets("Tracker").Range("C3", Worksheets("Tracker").Cells(Rows.Count, "C").End(xlUp)) For Each cell In Rng.Cells If cell.Offset(0, 6).Value = "" Then matchFoundIndex = WorksheetFunction.Match(cell.Value, Rng, 0) If cell.Value = matchFoundIndex Then cell.Offset(0, 6).Value = "Single" Else cell.Offset(0, 6).Value = "Multiple" End If End If Next cell End If End Sub
Please note: This post is a cross post from below link.