+ Reply to Thread
Results 1 to 7 of 7

Search/delete

  1. #1
    Forum Contributor Jerry HKA's Avatar
    Join Date
    09-25-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    126

    Search/delete

    Hello,

    I need a VBA codes that can search the whole worksheet for a number that I typed into a particular cell, and delete it.

    That means if I typed 1256 in S3, and activated a macro or a VBA code(function), the computer shall search worksheet for same numbers in any arrangements and delete it.

    Can anybody make one, or even have an idea for it? If yes, then, please try.

    Thank you.

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Search/delete

    Give this a try:

    Please Login or Register  to view this content.
    Gary's Student

  3. #3
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: This macro better

    PHP Code: 
    Option Explicit
    Sub Jerry_HKA
    ()
     
    Dim Rng As RangesRng As RangedRg As Range
     Dim MyAdd 
    As String
     
     Set Rng 
    ActiveSheet.UsedRange:       Set dRg = [s3]
     
    Set sRng Rng.Find(dRg.Value, , xlFormulasxlWhole)
     If 
    Not sRng Is Nothing Then
        MyAdd 
    sRng.Address
        
    Do
            
    Set dRg Union(dRgsRng)
            
    Set sRng Rng.FindNext(sRng)
        
    Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
     End 
    If
     If 
    Not dRg Is Nothing Then dRg.Value "" 
    End Sub 

  4. #4
    Forum Contributor Jerry HKA's Avatar
    Join Date
    09-25-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    126

    Re: Search/delete

    Any code that can also delete any numbers inside it. That means if I use
    Please Login or Register  to view this content.
    to delete 3459, I also want it yo delete 345,349,359 and 459. If I want to delete 8883, i want it to also delete, 388 and 888. Do you understand??? Please try to. If not, then PM me. I will explain.

  5. #5
    Forum Contributor Jerry HKA's Avatar
    Join Date
    09-25-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    126

    Re: This macro better

    And addition to it, it won't delete the permutation of the numbers, which also means If I want to delete 1234, the computer must also delete 4321,1324,3421,4132 and so on. That means it must delete every possible arrangements of the number. Please approach the code again and configure it to perfection.

    Thank you in advanced, I know you guys could do it.

  6. #6
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Select value in [S5],

    Attached Files Attached Files

  7. #7
    Forum Contributor Jerry HKA's Avatar
    Join Date
    09-25-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    126

    Re: Search/delete

    Thank you for your code or function, first of all, can you tell me how you did that and secondly, what does it mean by select value. Can you please explain to me, please. I am not very good at understanding these method just by looking at them. Please explain, Thank you.

+ Reply to Thread

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