Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Find & replace with VBA

Good day, i pleeeease need some help with the following:

(I am not a programmer so it may be a bit clumsy)

I am downloading a spreadsheet from SAP in wk1 format. The columns with
dates in, i format so that i can use the spreadsheet in Access; by using
the following code:

The original format is: 20040501

Range("H:H,L:L,M:M,T:T,X:X,AB:AB").Select
Selection.NumberFormat = "d-mmm-yy"

Columns("H:H").Select
Selection.TextToColumns Destination:=Range("H1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(0, 5), TrailingMinusNumbers:=True

It then looks like: 01-May-04, which is great.

However my problem is the fields that contain this:
00000000, this then becomes 01-Jan-00 and in the formula bar it looke
like this 1900/01/00.
I then need to remove this so i used the macro recorder and searched for
1900/01/00 and replaced with nothing, it worked but when i try and run
the code it won't work?
I then replaced the search criteria with 01-Jan-00 and it still does not
work ?

If i use the search function, manually, it finds 1900/01/00.

Any help is very welcome.

Les Stout

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Find & replace with VBA

Tempy wrote ...

I am downloading a spreadsheet from SAP in wk1 format. The columns with
dates in, i format so that i can use the spreadsheet in Access; by using
the following code:

The original format is: 20040501

Range("H:H,L:L,M:M,T:T,X:X,AB:AB").Select
Selection.NumberFormat = "d-mmm-yy"

Columns("H:H").Select
Selection.TextToColumns Destination:=Range("H1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(0, 5), TrailingMinusNumbers:=True

It then looks like: 01-May-04, which is great.

However my problem is the fields that contain this:
00000000, this then becomes 01-Jan-00 and in the formula bar it looke
like this 1900/01/00.


Try

.NumberFormat = "d-mmm-yy;;"

Because you are using the data elsewhere, I wouldn't recommend
replacing the zeros with empty string. This could cause an undesirable
mixed types situation (see
http://www.dicks-blog.com/excel/2004...l_data_m.html). You
will have to handle the situation where the date is zero which is a
valid date value. BTW note that with the Jet provider the following
query:

SELECT DAY(0), MONTH(0), YEAR(0)

returns 30, 12, 1899 respectively.

Jamie.

--
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Find & replace with VBA

Thanks jamie, it works great.

Sorry for the time delay, it is now 12:20 by me.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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 & Replace: find part cell, replace whole cell katy Excel Worksheet Functions 3 April 3rd 23 01:20 PM
Find and Replace - Replace with Blank Space Studebaker Excel Discussion (Misc queries) 4 April 3rd 23 10:55 AM
where to put results of find operation in find and replace functio DEP Excel Worksheet Functions 5 November 15th 06 07:52 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
find replace cursor default to find box luffa Excel Discussion (Misc queries) 0 February 3rd 05 12:11 AM


All times are GMT +1. The time now is 02:36 PM.

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"