ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   manual and macro run differences (https://www.excelbanter.com/excel-programming/428100-manual-macro-run-differences.html)

[email protected][_2_]

manual and macro run differences
 
Columns("A:A").Select
Selection.Replace What:="2009", Replacement:="09", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

When I do it manually above replacement I received good results
(Text to date conversion)
But when record and run as macro I received comical result.
I really wonder why ? Any idea why this happens ? Thank you.

AltaEgo

manual and macro run differences
 
Are you trying to change the format of something already recorded as a date?
If so, find and replace is not the way to achieve the desired result. You
need to format your date field according to you preferences.

In the worksheet, refer to the Text() function. In VBA see the Format()
function.

--
Steve

wrote in message
...
Columns("A:A").Select
Selection.Replace What:="2009", Replacement:="09", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

When I do it manually above replacement I received good results
(Text to date conversion)
But when record and run as macro I received comical result.
I really wonder why ? Any idea why this happens ? Thank you.



[email protected][_2_]

manual and macro run differences
 
On May 7, 9:52*am, "AltaEgo" <Somewhere@NotHere wrote:
Are you trying to change the format of something already recorded as a date?
If so, find and replace is not the way to achieve the desired result. You
need to format your date field according to you preferences.

In the worksheet, refer to the Text() function. In VBA see *the Format()
function.

--
Steve

wrote in message

...



Columns("A:A").Select
Selection.Replace What:="2009", Replacement:="09", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False


When I do it manually above replacement I received good results
(Text to date conversion)
But when record and run as macro I received comical result.
I really wonder why ? Any idea why this happens ? Thank you.- Hide quoted text -


- Show quoted text -



Hi Steve, thank you for your reply.
I copy a word table into excel as text but date field doesnt't work.
So when I manually change 2009 to 09 whole column becomes proper date.
I recorded the replacement into a macro and run but the result is
different than manual replacement.
If only i managed to run some word vba codes through excel like
replacement as i have to do some other replacements after copying the
table.

AltaEgo

manual and macro run differences
 
To convert your text dates to proper dates, use the Datevalue() function

If you have a text date in A1:

=Datevalue(A1)

You will see a number in the cell in which you entered the above formula. to
change this to a date, Format the cell and choose your date formula.

To get this back into A1 in place of the original value, copy, paste
special, value.

--
Steve

wrote in message
...
On May 7, 9:52 am, "AltaEgo" <Somewhere@NotHere wrote:
Are you trying to change the format of something already recorded as a
date?
If so, find and replace is not the way to achieve the desired result. You
need to format your date field according to you preferences.

In the worksheet, refer to the Text() function. In VBA see the Format()
function.

--
Steve

wrote in message

...



Columns("A:A").Select
Selection.Replace What:="2009", Replacement:="09", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False


When I do it manually above replacement I received good results
(Text to date conversion)
But when record and run as macro I received comical result.
I really wonder why ? Any idea why this happens ? Thank you.- Hide
quoted text -


- Show quoted text -



Hi Steve, thank you for your reply.
I copy a word table into excel as text but date field doesnt't work.
So when I manually change 2009 to 09 whole column becomes proper date.
I recorded the replacement into a macro and run but the result is
different than manual replacement.
If only i managed to run some word vba codes through excel like
replacement as i have to do some other replacements after copying the
table.




All times are GMT +1. The time now is 11:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com