Edit each cells but only unique one using vba

Important Notice


Please note that on 14th December 2023 users will experience an expected outage whilst we make upgrades to our network. We anticipate this process may take a couple of hours and so we apologise in advance for any inconvenience.

  • hi, everyone
    i am using below code to edit every cell in range.("C10:C300"),
    but
    now its checking every cell and edit him,
    but
    i want it edit only unique data,
    for example -


    cell 10 have data = haroon, then edit it
    cell 11 have data = alan, then edit it
    cell 12 have data = haroon, the skip it




    thanx in advance

  • Re: Edit each cells but only unique one using vba


    So all further instances of "haroon" need to be left as "haroon" or changed to whatever the first instance was changed to?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Edit each cells but only unique one using vba


    If just first instance to be changed then try this


    If all instances to be changed then try this

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Edit each cells but only unique one using vba


    mod,
    i have a another question to related this thread,


    is it possible to edit unique range without inputbox?
    i mean when i run the code it edit unique cell without showing inputbox


    or should i start a new thread?

  • Re: Edit each cells but only unique one using vba


    It could be done if every cell needed to be edited the same.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Edit each cells but only unique one using vba


    The original question also posted on ExcelForum, no links in either forum.
    Can't see the supplementary question yet. Give it time

  • Re: Edit each cells but only unique one using vba


    How do you need the cells edited?


    Also which code are you using, the one that changes just the first instance of a particular value or the one that changes all instances of that value?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Edit each cells but only unique one using vba


    Sub Haroon2015_RangeEditing()
    Dim rCell As Range, vAns As Variant
    Redim x(1 To 1)

    On Error Goto ErrHndlr 'check there is at least one cell in c10:c300 with a value
    [c10:c300].SpecialCells(2).Select
    For Each rCell In Selection
    If IsError(Application.Match(rCell, x, 0)) Then
    vAns = InputBox("Edit cell if wanted", "Edit cell ", rCell)
    Redim Preserve x(1 To UBound(x) + 1)
    x(UBound(x)) = rCell
    If Not vAns = "" Then rCell = vAns
    End If
    Next
    ErrHndlr:

    End Sub



    I AM USING THIS CODE

  • Re: Edit each cells but only unique one using vba


    OK, but how do you want each unique value to be edited?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Edit each cells but only unique one using vba


    Quote from haroon2015;781948

    one by one c10 to last added data


    I really do not understand what you mean by that. What is "last added data?


    Can you please attach a sample workbook that shows a sample of your data in Column C and your desired result.
    [sw]*[/sw]

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Edit each cells but only unique one using vba


    Hi, kjbox
    as u know my range is c10:c300, ok


    which cells i want to added using macro?

    Quote

    one by one, c10 to last added data


    in above under quote line means
    i add data to c10, then c11, then 12, then 13..........to 30
    now code only added cells c10 to c30


    if i have data in range c10:c50
    then edit only c10 to c50


    let me know if you want to know more about my requirement

  • Re: Edit each cells but only unique one using vba


    Yes I understand all that already.


    You said you wanted to do away with the Input Box and I explained that to do so was possible if the same editing was to be used on each unique value.


    I need to know what that editing is like.


    So, from your example in the opening post, what does "haroon" need to be edited to? What does "alan" need to be edited to?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Edit each cells but only unique one using vba


    Because i need to edit a cell


    it activate a another macro ( Private Sub Worksheet_Change(ByVal Target As Range) )


    edit means just like u select a cell and just press f2

  • Re: Edit each cells but only unique one using vba


    You're welcome.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!