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

I have the following script below, but I would like to have it search for
the word "hours" and replace it with a null value, so it would just display
1.25. I'm a little new to VB so I'm assuming that the "Select Case
cell.Value" is searches for the entire value of the cell rather than a value
within the cell. What would I need to do?



Sub MyReplace()
Dim cell As Range


For Each cell In Range("e1:e5000")


Select Case cell.Value


Case "1.25 hours"
cell = "1.25"

End Select
Next cell
Set cell = Nothing


End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Find and Replace

How about...
Selection.Replace What:=" hours", _
Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

I just tried to do it with the macro recorder turned on
and got the code above. This is an easy way to figure out
a lot of programming issues. Another way is to get John
Walkenbach's Excel 2002 Power Programming with VBA.
Check out...
http://www.j-walk.com/ss/books/xlbook25.htm

HTH,
Gary Brown



-----Original Message-----
I have the following script below, but I would like to

have it search for
the word "hours" and replace it with a null value, so it

would just display
1.25. I'm a little new to VB so I'm assuming that

the "Select Case
cell.Value" is searches for the entire value of the cell

rather than a value
within the cell. What would I need to do?



Sub MyReplace()
Dim cell As Range


For Each cell In Range("e1:e5000")


Select Case cell.Value


Case "1.25 hours"
cell = "1.25"

End Select
Next cell
Set cell = Nothing


End Sub


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Find and Replace

hi,
just a suggestion. why not copy the e column and paste in
on a new sheet then parse the "hours" out.
datatext to columns.
then you can copy the numbers and paste them back in the e
column then delete the new sheet.
yeah, crude. yeah, manual. just a suggestion.

-----Original Message-----
I have the following script below, but I would like to

have it search for
the word "hours" and replace it with a null value, so it

would just display
1.25. I'm a little new to VB so I'm assuming that

the "Select Case
cell.Value" is searches for the entire value of the cell

rather than a value
within the cell. What would I need to do?



Sub MyReplace()
Dim cell As Range


For Each cell In Range("e1:e5000")


Select Case cell.Value


Case "1.25 hours"
cell = "1.25"

End Select
Next cell
Set cell = Nothing


End Sub


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Find and Replace

I export my time from Outlook and calculating the time. I would like to make
it as automated as possible. Thanks for the info.

wrote in message
...
hi,
just a suggestion. why not copy the e column and paste in
on a new sheet then parse the "hours" out.
datatext to columns.
then you can copy the numbers and paste them back in the e
column then delete the new sheet.
yeah, crude. yeah, manual. just a suggestion.

-----Original Message-----
I have the following script below, but I would like to

have it search for
the word "hours" and replace it with a null value, so it

would just display
1.25. I'm a little new to VB so I'm assuming that

the "Select Case
cell.Value" is searches for the entire value of the cell

rather than a value
within the cell. What would I need to do?



Sub MyReplace()
Dim cell As Range


For Each cell In Range("e1:e5000")


Select Case cell.Value


Case "1.25 hours"
cell = "1.25"

End Select
Next cell
Set cell = Nothing


End Sub


.



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 11:35 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"