Results 1 to 5 of 5

Delete a character in a cell, but skip cell if not present

Threaded View

  1. #1
    Registered User
    Join Date
    01-07-2011
    Location
    Stamford, England
    MS-Off Ver
    Excel 2007
    Posts
    13

    Delete a character in a cell, but skip cell if not present

    I have a sub that deletes a . if it is found in a cell for a range of cells. It runs fine if there is a . present but if there isn't it stops my sub. Is there anyway i can skip over the cell if it doesn't contain a . ?
    My code is

    Sub CalcEffy()
    Dim i As Long
    i = 57
    With Sheets("Design Database")
        Do While i <= .Rows.Count
        If .Cells(i, 2) <> "" Then
        
    Sheets("Design Database").Range("B" & i).Select
    Selection.Find(What:=".", After:=ActiveCell, LookIn:=xlValues, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate
    
    Selection.Replace What:=".", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    
    Selection.Replace What:="-", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    
               Else
                    Exit Do
                End If
                i = i + 1
            Loop
        End With
    End Sub
    Last edited by Riosmitham; 01-24-2011 at 07:36 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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