+ Reply to Thread
Results 1 to 19 of 19

find same value in a range and clearcontents

  1. #1
    Forum Contributor
    Join Date
    03-28-2017
    Location
    Thailand
    MS-Off Ver
    2013
    Posts
    241

    find same value in a range and clearcontents

    Hi,

    In the RangeA160:A170 sometimes appears some names (api macro).
    I want he compare the name in Range B2:B155 and clear it out there.
    I not sure how many names come after macro run, can be 1, 3, 0, 8 ...

    so I need in VBA loop A160 till last filled cell,
    find same value in B range
    clear cell content

    Thank you
    Christian
    Last edited by incobart; 07-15-2019 at 11:18 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: find same value in a range and clearcontents

    Provide a sample workbook, please (you should know this by now).
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    03-28-2017
    Location
    Thailand
    MS-Off Ver
    2013
    Posts
    241

    Re: find same value in a range and clearcontents

    Hi, here an example workbook to make it more easy.

    Someone can help me out ?

    Thanks
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    03-28-2017
    Location
    Thailand
    MS-Off Ver
    2013
    Posts
    241

    Re: find same value in a range and clearcontents

    nobody know how to do ?

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: find same value in a range and clearcontents

    A comment like that accompanied by the rolling eyes emoticon is not likely to endear you to anyone who does.

    You do realise, don't you, that all the help you get here is free and offered by generous volunteers?

    If you are going to bump your thread, which is absolutely fine in itself after a day, then do it politely.

  6. #6
    Forum Contributor
    Join Date
    03-28-2017
    Location
    Thailand
    MS-Off Ver
    2013
    Posts
    241

    Re: find same value in a range and clearcontents

    I didn't mean like this, sorry, I just wanted to do a recall, cause I see nobody look anymore, I wanted to put tears, but it was not available
    This is a great website, and the best for excel problems, always thank full and following the rules, only negative is the sometimes difficult moderator

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: find same value in a range and clearcontents

    Personal comments about moderators are unacceptable - please don't do that again.

    Next time you bump a thread, please do it in a thoughtful way.

    If anyone can help, they will. Usually when threads go unanswered it's because the query is in some way unclear, so perhaps think about what else you can add to make it easier for those who might help you.

  8. #8
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: find same value in a range and clearcontents

    ill take a look at it and see if i can find a solution to your issue

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

    Arrow s

    Quote Originally Posted by incobart View Post
    nobody know how to do ?
    It seems your attachment does not reflect your initial 'explanation' …
    As it's very not difficult to well explain your need and to attach a before workbook and an expected result workbook (after) accordindly …

  10. #10
    Forum Contributor
    Join Date
    03-28-2017
    Location
    Thailand
    MS-Off Ver
    2013
    Posts
    241

    Re: find same value in a range and clearcontents

    Hey, Thank you so much ! DmcGov
    Last edited by incobart; 07-15-2019 at 12:19 PM.

  11. #11
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: find same value in a range and clearcontents

    so i have to agree with marc in that the workbook doesn't match what you are saying in post #1.

    please fill in the blank

    Please Login or Register  to view this content.
    this doesn't seem like an issue, just need to know the details.

  12. #12
    Forum Contributor
    Join Date
    03-28-2017
    Location
    Thailand
    MS-Off Ver
    2013
    Posts
    241

    Re: find same value in a range and clearcontents

    Hi Dmcgov,
    Thanks for checking, sorry for the late reply, but it was night here, ok I explain like in the example

    at this moment, the api give me 3 values in range A160:A170 --> senegal cuba and Mali

    I would like that the macro go to this names in B2:B155 range find them en make empty cell

    so in this case he must find that Senegal is in cell B122, and empty the cell B122, then find that Cuba is in B30, empty B30 then find that Mali is in B80 and empty the cell B80 end loop check

    the next hour it can be other names in range A160:170 (when api runs again) and then do the procedure again

    Thank you

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

    Cool

    A demonstration according to your attachment as a beginner starter :

    PHP Code: 
    Sub Demo()
                
    Dim VRg As Range
                
    If IsEmpty([A160]) Then Beep: Exit Sub
        With Range
    ("B2", [B1].End(xlDown))
            For 
    Each V In Range("A160"Cells(Rows.Count1).End(xlUp)).Value2
                      Set Rg 
    = .Find(V, , xlValuesxlWhole)
                While 
    Not Rg Is Nothing
                          Rg
    .Clear
                      Set Rg 
    = .FindNext(Rg)
                
    Wend
            Next
        End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  14. #14
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: find same value in a range and clearcontents

    Or
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    03-28-2017
    Location
    Thailand
    MS-Off Ver
    2013
    Posts
    241

    Re: find same value in a range and clearcontents

    Hi jolivannes, Thanks for your Help, I started testing your code and it works ! only 1 issue, when only one value come in A160, then he debug, type mismatch, when i have more there is no problem ... any idea ?

    greets
    christian

  16. #16
    Forum Contributor
    Join Date
    03-28-2017
    Location
    Thailand
    MS-Off Ver
    2013
    Posts
    241

    Re: find same value in a range and clearcontents

    Hi Marc L, Thanks for your Help, I started testing your code

    it seems to debug on this line :
    Please Login or Register  to view this content.
    I get the message runtime error 424 object required
    any idea ?
    greets
    Christian

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

    Arrow


    Nope ! As it rocks with your attachment on my side ! But jolivanes' code is a better way …

  18. #18
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: find same value in a range and clearcontents

    Please Login or Register  to view this content.

  19. #19
    Forum Contributor
    Join Date
    03-28-2017
    Location
    Thailand
    MS-Off Ver
    2013
    Posts
    241

    Re: find same value in a range and clearcontents

    Hi,
    maybe because the wb I send is just a simple example, its part of a big complex macro's running file that it interfere with something " (Marc) but on itself it works ok. Thanks
    The new code from Jolivanes gives exactly what I want and simple, Thans for your help also !!
    have a nice day !
    Christian

+ 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] ClearContents with Range
    By Keibri in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-06-2019, 12:52 PM
  2. excel range.clearcontents() API hanging
    By Raj Abhishek in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-11-2015, 04:00 AM
  3. [SOLVED] Range clearcontents
    By tradinup2 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-12-2013, 03:38 PM
  4. [SOLVED] Clearcontents on a range is cause a runtime error
    By dagindi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-04-2012, 03:35 PM
  5. Clearcontents of range on multiple worksheets
    By stephenw in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-28-2007, 10:37 AM
  6. Combining find with clearcontents on multiple columns
    By RussB in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2006, 07:25 PM
  7. [SOLVED] ClearContents method on a passed range
    By bryan in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 01-19-2005, 05:06 AM

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