Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Find and Replace Dates in VBA

If you select a block of cells and run the macro, any cell containing
00/01/1900 will be cleared.
--
Gary''s Student - gsnu200753


"Ladymuck" wrote:

Didn't realise, will try again although I have to say I don't understand
quite what it's doing. Will this replace all instances of 00/01/1900 with an
empty cell? There are no empty cells - they are all filled with dates.

"Gary''s Student" wrote:

This requires you to select a group of cells prior to running the macro.
--
Gary''s Student - gsnu200753


"Ladymuck" wrote:

Sorry if this is a duplicate post, internet connection having a funny five
minutes.

Nothing seemed to happen when I ran this solution.

"Gary''s Student" wrote:

Give this a try:

Sub ladym()
Set rr = Nothing
For Each r In Selection
If r.Text = "00/01/1900" Then
If rr Is Nothing Then
Set rr = r
Else
Set rr = Union(rr, r)
End If
End If
Next
If rr Is Nothing Then
Else
rr.Clear
End If
End Sub

--
Gary''s Student - gsnu200753


"Ladymuck" wrote:

If I do CRTL+ H and type in 00/01/1900 and set it to replace with nothing, it
works fine. However, when I insert the following code into my VBA project,
nothing happens. I took it straight from the good old Macro recorder!

Cells.Replace What:="00/01/1900", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Removing the quotes automatically changed it to this, with the same result:
Cells.Replace What:=0 / 1 / 1900, Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

What have I done wrong, or what do I need to? I know this is basically zero
in date format but I don't want to replace everything that is 0, just those
looking like a date

Many thanks for your help.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Replace - Replace with Blank Space Studebaker Excel Discussion (Misc queries) 4 April 3rd 23 10:55 AM
Find/Replace Event or Find/Replace for Protected Sheet ... Joe HM Excel Programming 2 October 27th 07 03:55 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
Using Find and Replace to replace " in a macro snail30152 Excel Programming 1 April 13th 06 11:58 PM
Replace method - cannot find any data to replace Mike Excel Programming 5 April 6th 06 08:56 PM


All times are GMT +1. The time now is 11:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"