Instead of using Cells as the starting reference range, use a more
restricted range and the search/replace will occur within that range only.
For example, to modify your posted code to handle, say, Column B only...
Sub dateconvert()
Range("B:B").Replace What:="Aug-28-2008", Replacement:="8/28/2008", _
LookAt:=xlPart, SearchOrder:=xlByRows, _
MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
--
Rick (MVP - Excel)
Where do you see that apostrophe in front of the text... in the cell and
Formula Bar or only in the Formula Bar? Either way, the first thing to do
is
select all your "dates" (which are really text that look like a date).
Then,
if you see the apostrophe in the cell, then click Edit/Replace on Excel's
menu bar, put an apostrophe (') in the "Find what" field, leave the
"Replace
with" field empty and click OK. Now, do the following for either case...
the
cells where we just removed the apostrophe or for the case where the
apostrophe was only in the Formula Bar... click Data/TextToColumn, click
Next twice on the dialog box that appears, select the "Date" option button
in the "Column data format" section on the dialog page you end up on after
clicking Next the second time, then click the Finish button. Your entries
should now be real dates that you can use Format/Cell (from Excel's menu
bar) to make it display anyway that you want.
--
Rick (MVP - Excel)
- Show quoted text -
Rick, if I am searching and replacing xcontents in a cell, how do I
specify SearchOrder: to just search one column, or one row????