Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro search replace question

We're trying to eliminate all occurances of 4 numbers followed by a colon
and a space (1234: ) in the begining of the string. We've tried find("????:
", A1) but it finds everything.

Does anyone know a simple way ???

Bill



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Macro search replace question

I make the assumptions that the data is in column A and that you have
"####: " at the beginning of the text and may be in the middle of the text
as well. Make a copy of your file before you try this.

Sub rep()
Dim xC As Range, pos1 As Long, pos2 As Long
Dim str1 As String
For Each xC In ActiveSheet.Range(Cells(1, "A"), Cells(65536, "A").End(xlUp))
str1 = xC.Text
If Len(str1) Then
pos1 = InStr(str1, ": ") + 2 'leading "*: "
str1 = Mid$(str1, pos1)
pos2 = InStr(str1, ": ") 'second "*: "
If pos2 Then
pos1 = InStrRev(str1, " ", pos2)
str1 = Left$(str1, pos1) & Mid$(str1, pos2 + 2)
End If
xC = str1
End If
Next
End Sub

As an example to include other columns, say columns A to C, change
Cells(65536,"A") to Cells(65536,"C")


I'm at standstill with about 2,000,000 records to clean. The problem is
that it's in the beginning the string:

34554: roigeoig t4gi4goi4oi t4giht4ih5t t4gt4g 54g 4g6ht4 2655467:

igroi54g
54gg

We can't remove the second occurance of the search string



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
Macro Search and Replace [email protected] Excel Discussion (Misc queries) 2 September 23rd 08 01:13 PM
Search and Replace Question Rebecca New Users to Excel 1 April 11th 05 04:49 AM
Simple Search and Replace Question Rebecca Excel Discussion (Misc queries) 2 April 3rd 05 03:33 PM
macro to search and replace with offset Tim Excel Discussion (Misc queries) 5 December 11th 04 09:30 PM
search & replace joe_may Excel Worksheet Functions 1 November 8th 04 11:16 PM


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

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

About Us

"It's about Microsoft Excel"