Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 03-28-2016, 08:45 PM
Philb1 Philb1 is offline Macro to Find and Replace Does Not Work - But Works Manually Windows 10 Macro to Find and Replace Does Not Work - But Works Manually Office 2010 32bit
Advanced Beginner
 
Join Date: Feb 2016
Location: Auckland
Posts: 43
Philb1 is on a distinguished road
Default

Hi Rod
With the example you gave the code below will change any cell with a date in the range on column I to 4/5
Using Replace will work for a range of cells with the same date, if there are different dates you will still have to loop through the dates.
This is a start, if you want more help can you provide more detail & a better example etc
Code:
Option Explicit

Sub ReplaceDates()

Dim Ws As Worksheet
Dim Rcell As Range
Dim sReplaceWith As String
sReplaceWith = "4/5"

Set Ws = ThisWorkbook.ActiveSheet

For Each Rcell In Ws.Range(Ws.Cells(19, 9), Ws.Cells(Rows.Count, 9).End(xlUp))
    If IsDate(Rcell) Then
        With Rcell
            .NumberFormat = "@"
            .Value = sReplaceWith
        End With
    End If
Next Rcell

End Sub
Reply With Quote
 

Tags
find/replace macro not wk



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Find and Replace Does Not Work - But Works Manually Find and Replace doesn't work. Bop70 Word 3 02-04-2015 11:45 AM
Find and replace No longer work TJH Word 3 03-25-2014 11:33 PM
Macro to Find and Replace Does Not Work - But Works Manually Find and Replace Macro amparete13 PowerPoint 3 03-11-2014 05:29 AM
macro or find/replace JamesVenhaus Word 2 02-27-2012 03:34 PM
Find and Replace Macro - A Better Way Tribos Word VBA 0 10-08-2008 03:22 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft