+ Reply to Thread
Results 1 to 21 of 21

Repair Value From Unique Range

  1. #1
    Registered User
    Join Date
    04-07-2019
    Location
    Madagascar
    MS-Off Ver
    2013
    Posts
    43

    Red face Repair Value From Unique Range

    Hi Expert,
    I am trying to fix the code, the sheet has three columns, the first one is serial and the second one is equivalent text and the third one is the value, the value of column C is wrong, we have to find it.
    Column B has a unique range reference that will check the value in column C. The value of column C is accidentally pulled but still a value is correct.
    What are the values ​​in column C that make it different, we have to persist and fill it to the limit unique range to column B.
    I hope you understand.

    Thank you
    Attached Files Attached Files
    Last edited by jessica0007; 11-24-2019 at 09:07 PM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Post

    (removed as I saw the light …)
    Last edited by Marc L; 11-24-2019 at 02:28 PM.

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this ‼


    According to your attachment a starter demonstration :

    PHP Code: 
    Sub Demo1()
                
    Dim Rg As RangeV
                Application
    .ScreenUpdating False
        With 
    [A1].CurrentRegion.Columns(2)
                
    Set Rg = .Cells(12)
            While 
    Not IsEmpty(Rg(Rg.Count)(20))
                
    Set Rg Range(Rg(Rg.Count)(2), .Find(Rg(Rg.Count)(20), , xlValuesxlWhole, , xlPrevious)(12))
                
    Filter(Application.Transpose(Rg), Rg(0), False)
                If 
    LBound(V) = 0 Then Rg.Value2 V(0)
            
    Wend
        End With
                Application
    .ScreenUpdating True
                Set Rg 
    Nothing
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 11-24-2019 at 03:09 PM. Reason: optimization …

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Repair the code

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however the thread title does not really convey what your request is about.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Repair the code

    (removed as I saw the light …)
    Strong the Force with you is...
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  6. #6
    Registered User
    Join Date
    04-07-2019
    Location
    Madagascar
    MS-Off Ver
    2013
    Posts
    43

    Re: Hi ! Try this ‼

    @Marc L, your code is working perfectly as per requested.
    I have changed the column space. The unique range of column B has been set in column E, and the value of column C has been set in column M.
    Will you change the vba code again, because I do not know much about vba code.
    Thank you
    Attached Files Attached Files
    Last edited by jessica0007; 11-24-2019 at 08:43 PM.

  7. #7
    Registered User
    Join Date
    04-07-2019
    Location
    Madagascar
    MS-Off Ver
    2013
    Posts
    43

    Re: Repair the value

    @alansidman, From next time I will make sure that my title is correct. I sent it in a hurry, I should have taken care that after reading the title the experts will be able to help me properly.

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool

    Quote Originally Posted by sintek View Post
    Strong the Force with you is...
    Maybe Yoda but I saw the dark side …


    Quote Originally Posted by jessica0007 View Post
    I have changed the column space.
    Thanks for the rep' !

    According to your last attachment my demonstration revamped :

    PHP Code: 
    Sub Demo1r()
                
    Dim Rg As RangeV
                Application
    .ScreenUpdating False
        With ActiveSheet
    .UsedRange.Columns(5)
                
    Set Rg = .Cells(19)
            While 
    Not IsEmpty(Rg(Rg.Count)(2, -7))
                
    Set Rg Range(Rg(Rg.Count)(2), .Find(Rg(Rg.Count)(2, -7), , xlValuesxlWhole, , xlPrevious)(19))
                
    Filter(Application.Transpose(Rg), Rg(0), False)
                If 
    LBound(V) = 0 Then Rg.Value2 V(0)
            
    Wend
        End With
                Application
    .ScreenUpdating True
                Set Rg 
    Nothing
    End Sub 

  9. #9
    Registered User
    Join Date
    04-07-2019
    Location
    Madagascar
    MS-Off Ver
    2013
    Posts
    43

    Re: Repair Value From Unique Range

    Marc L, Perfect and Thank you very much for rewriting the code.

  10. #10
    Registered User
    Join Date
    04-07-2019
    Location
    Madagascar
    MS-Off Ver
    2013
    Posts
    43

    Re: Repair Value From Unique Range

    Mark L, I have been using your code for a long time but your answer is not coming right in this sheet. Please see the attached file.
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question

    Bad sheet ! As according to your post #6 where

    Quote Originally Posted by jessica0007 View Post
    I have changed the column space. The unique range of column B has been set in column E, and the value of column C has been set in column M.
    … the question is why in the last attachment the column M is empty ?‼

    With column M filled if the result is not the expected one
    that means the data does not respect the original logic, so you have to correct cells manually
    or to create a new thread with this time the best logic explanation and an attachment accordingly …

  12. #12
    Registered User
    Join Date
    04-07-2019
    Location
    Madagascar
    MS-Off Ver
    2013
    Posts
    43

    Re: Repair Value From Unique Range

    Hi Mark L,
    Sorry, one column is deleted, and the other thing is that if it does not find any unique value in the column M, it will skip and check the next row.
    Last edited by jessica0007; 11-29-2019 at 11:26 AM.

  13. #13
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Just add a column in order data are within column M …

    As both codes do not work with 'unique value' or according to your both first attachments they couldn't work as expected !

    So from the initial post & post #6 this thread is solved …
    For new rules, I think it's better you create a new thread with this time a smart explanation of the expected logic to follow
    - missing in the initial post of this thread - and a before / after attachment accordingly
    in a well defined context, never changing each time you add a new post …

  14. #14
    Registered User
    Join Date
    04-07-2019
    Location
    Madagascar
    MS-Off Ver
    2013
    Posts
    43

    Re: Repair Value From Unique Range

    Yes I agree that this Thread has been resolved as per my request, but I do not think that another Thread should be made, for a small problem so far you have helped me a lot of time. I request you one more time. please do it.

  15. #15
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow


    As I can't help without any logic well explained …

  16. #16
    Registered User
    Join Date
    04-07-2019
    Location
    Madagascar
    MS-Off Ver
    2013
    Posts
    43

    Re: Repair Value From Unique Range

    I can try to explain logic,
    From the unique range in column E, we were looking for the correct value of column M, but sometimes the value of column M is also correct, as if we could not find a different value from column m then it means that Correct, keep it that way. Do not make any changes in it and try to find it from the next unique range.

  17. #17
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    In fact the issue comes from your data not respecting the initial context :
    the 'Unique Range' column is no more unique as it has duplicates blocks ‼

    As my way can't work anymore, as it's a new context just create a new thread …

  18. #18
    Registered User
    Join Date
    04-07-2019
    Location
    Madagascar
    MS-Off Ver
    2013
    Posts
    43

    Re: Repair Value From Unique Range

    I think I have given the wrong excel file, I have attached another file, you will understand by looking at it.
    Otherwise I will request a new Thread this time.
    Sorry for trouble...
    Attached Files Attached Files
    Last edited by jessica0007; 11-30-2019 at 09:07 AM.

  19. #19
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    According to the last attachment Test4, even if UBound >= 0 must replace LBound = 0

    as there is no matching logic for a part of your expected result
    so without a crystal clear explanation I can't waste my time anymore …

  20. #20
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Exclamation


    For attachment Test5 as there are duplicates in the 'unique' column just forget my code !

  21. #21
    Registered User
    Join Date
    04-07-2019
    Location
    Madagascar
    MS-Off Ver
    2013
    Posts
    43

    Re: Repair Value From Unique Range

    Thank you for your valuable time. I will always be thankful to you and I sincerely apologize for everything that has caused you trouble.

+ 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. [SOLVED] Repair Order System Pulling Records From ID Has Code Issues
    By fredfarmer in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-11-2019, 09:12 AM
  2. [SOLVED] Repair a code to transmit
    By AKRAMI in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-28-2015, 06:14 AM
  3. How to repair Excel.
    By parkman in forum Excel General
    Replies: 2
    Last Post: 03-04-2014, 05:12 PM
  4. [SOLVED] Repair vba code to userform.
    By satputenandkumar0 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-24-2013, 06:58 AM
  5. Code Repair - Copy Column to New Worksheet and Delet
    By RobGair in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-12-2010, 03:01 PM
  6. Code Repair - Copy Column to New Worksheet and Delete
    By RobGair in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-09-2010, 03:03 PM

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