Consulting

Results 1 to 4 of 4

Thread: Solved: Find / Replace not working - why?

  1. #1
    VBAX Contributor
    Joined
    Jun 2008
    Location
    West Midlands
    Posts
    170
    Location

    Solved: Find / Replace not working - why?

    Dear all,

    I am trying to replace a date in a column with a blank cell, the code written below does not work, yet when I use the exact same criteria manually on the spreadsheet it works, can anybody tell me what I am doing wrong?

    Your help is much appreciated.

    [VBA]Columns("al:al").Select
    Selection.NumberFormat = "dd/mm/yyyy"
    Selection.Replace What:="00/01/1900", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False[/VBA]

  2. #2
    VBAX Contributor
    Joined
    May 2008
    Location
    bangalore
    Posts
    199
    Location
    [vba]
    Sub ReplaceText()
    Dim c As Range
    For Each c In ActiveSheet.UsedRange
    c = Replace(c, "00/01/1900", "")
    Next
    End Sub
    [/vba]

  3. #3
    VBAX Contributor
    Joined
    May 2008
    Location
    bangalore
    Posts
    199
    Location
    u can run this macro

  4. #4
    VBAX Contributor
    Joined
    Jun 2008
    Location
    West Midlands
    Posts
    170
    Location
    Quote Originally Posted by shamsam1
    [vba]
    Sub ReplaceText()
    Dim c As Range
    For Each c In ActiveSheet.UsedRange
    c = Replace(c, "00/01/1900", "")
    Next
    End Sub
    [/vba]
    Sham,

    Thanks for your help, although I found this this works better.

    [VBA] With Columns("AL:AL")
    .NumberFormat = "0"
    .Replace What:=0, Replacement:="", LookAt:=xlWhole
    .NumberFormat = "dd/mm/yyyy"
    End With[/VBA]

Posting Permissions

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