Consulting

Results 1 to 7 of 7

Thread: Solved: Find & Replace problem

  1. #1
    VBAX Regular
    Joined
    Apr 2008
    Posts
    97
    Location

    Solved: Find & Replace problem

    I have a database that has zero values that I need to remove in specific columns.
    I need to find and replace any cells that contain only a 0 value within a specific range or column and replace it with ""

    I want to do this in VB but I need to figure out how to do a find and replace on only a specific column instead of it wanting to check the entire sheet.

    Thanks oh Excel gods....
    </IMG>

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Post a workbook, the words are not that clear.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Apr 2008
    Posts
    97
    Location
    Sorry about that.
    The data in yellow is what I would like to remove without removing any zero values everywhere else in the sheet.
    These two columns should never contain just a zero value but could contain values like 500, 20, or text similar to "Location had 0 number of signs"

    Thanks again.

  4. #4
    VBAX Regular
    Joined
    Jan 2006
    Posts
    21
    Location
    Hi slang,
    Is it a must to be done using VB? Otherwise, you can just select column L and M, use the find and replace function. The find value will be 0 and just leave the replace blank.

  5. #5
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Case you do want this in vba, this should work

    [VBA]Option Explicit
    Sub ElimZeros()
    Dim rngLookIn As Range
    Set rngLookIn = _
    Sheet1.Range(Cells(2, 12), _
    Cells( _
    Application.WorksheetFunction.Max(Cells(Rows.Count, 12).End(xlUp).Row, _
    Cells(Rows.Count, 13).End(xlUp).Row), 13))
    rngLookIn.Cells.Replace What:="0", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, _
    SearchFormat:=False, ReplaceFormat:=False
    End Sub[/VBA]

  6. #6
    VBAX Regular
    Joined
    Apr 2008
    Posts
    97
    Location

    Talking

    Thanks GTO!
    I would like it to run in VBA because I need this to be part of a patch that I will send to multiple users to fix their database local.

    Your code works great with the exception that it removes all zeros even if they are part of a number like 500 or 250 etc. I just replaced Lookat:=xlpart with xl:=whole and it works great.

    Thanks a lot!!!!!

  7. #7
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    OOPS; glad you caught my errorerer and got 'er working :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •