Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default wildcards in replace

I am trying to get rid of all cells that contain multiple ='s. For
instance in A13 it may read ===== === =========== =======. Then
in A40, it may read = ====== = ====. Basically these lines are
stopping my trim statements from running. I already have a line that
deletes all empty rows so it would be realy great if I could just get
rid of the characters all together and then delete teh row with that
line.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default wildcards in replace

Give this a try...

Public Sub test()
Call RemoveDuplicates("=")
End Sub

Public Sub RemoveDuplicates(ByVal ReplaceCharacter As String)
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range

Set wks = Sheets("Sheet1")
Set rngToSearch = wks.Cells
Set rngFound = rngToSearch.Find(What:=ReplaceCharacter & _
ReplaceCharacter, LookAt:=xlPart)

Do While Not rngFound Is Nothing
rngToSearch.Replace What:=ReplaceCharacter, _
Replacement:=""
Set rngFound = rngToSearch.Find(What:=ReplaceCharacter & _
ReplaceCharacter, LookAt:=xlPart)
Loop
End Sub
--
HTH...

Jim Thomlinson


" wrote:

I am trying to get rid of all cells that contain multiple ='s. For
instance in A13 it may read ===== === =========== =======. Then
in A40, it may read = ====== = ====. Basically these lines are
stopping my trim statements from running. I already have a line that
deletes all empty rows so it would be realy great if I could just get
rid of the characters all together and then delete teh row with that
line.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default wildcards in replace

Sorry htat was adapted from some old code that I had that needs a little
tweaking... Try this...

Public Sub test()
Call RemoveDuplicates("=")
End Sub

Public Sub RemoveDuplicates(ByVal ReplaceCharacter As String)
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range

Set wks = Sheets("Sheet1")
Set rngToSearch = wks.Cells.SpecialCells(xlCellTypeConstants)
Set rngFound = rngToSearch.Find(What:=ReplaceCharacter, LookAt:=xlPart)

Do While Not rngFound Is Nothing
rngToSearch.Replace What:=ReplaceCharacter, _
Replacement:=""
Set rngFound = rngToSearch.Find(What:=ReplaceCharacter,
LookAt:=xlPart)
Loop
End Sub

That gets rid of the ='s. Did you still need some help on the deleting rows?
--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Give this a try...

Public Sub test()
Call RemoveDuplicates("=")
End Sub

Public Sub RemoveDuplicates(ByVal ReplaceCharacter As String)
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range

Set wks = Sheets("Sheet1")
Set rngToSearch = wks.Cells
Set rngFound = rngToSearch.Find(What:=ReplaceCharacter & _
ReplaceCharacter, LookAt:=xlPart)

Do While Not rngFound Is Nothing
rngToSearch.Replace What:=ReplaceCharacter, _
Replacement:=""
Set rngFound = rngToSearch.Find(What:=ReplaceCharacter & _
ReplaceCharacter, LookAt:=xlPart)
Loop
End Sub
--
HTH...

Jim Thomlinson


" wrote:

I am trying to get rid of all cells that contain multiple ='s. For
instance in A13 it may read ===== === =========== =======. Then
in A40, it may read = ====== = ====. Basically these lines are
stopping my trim statements from running. I already have a line that
deletes all empty rows so it would be realy great if I could just get
rid of the characters all together and then delete teh row with that
line.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default wildcards in replace

Your a genius...thanks...worked great.

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
Replace with wildcards PDA Excel Discussion (Misc queries) 2 November 11th 09 01:20 PM
Edit and Replace with wildcards AJ[_4_] Excel Discussion (Misc queries) 2 April 1st 09 10:31 PM
Find and Replace with wildcards? Colin Excel Discussion (Misc queries) 4 January 20th 08 09:05 PM
Replace using Wildcards Stella Excel Worksheet Functions 1 June 23rd 06 06:48 PM
Replace using wildcards jeb Excel Discussion (Misc queries) 6 January 6th 05 03:35 PM


All times are GMT +1. The time now is 10:02 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"