Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Find and replace "?" character

Hello,

I have an easy question which I could solve so far.
I would like to find all ? character on a worksheet and delete it from each
cells.

My code is:

Private Sub CommandButton2_Click()
Dim rng1 As Range
Dim mycell1 As Range
Set rng1 = Range("h98:i100")
For Each mycell1 In rng1

If Not mycell1.Find("?") Is Nothing Then
mycell1.Replace What:="?", replacement:=""
End If
Next

End Sub


the result is, that it deletes each character, not just the ?s. My idea is,
that this is because ? is a special character to be used to look for
something which is not known in an expression.

How can I replace my ?s ? And onyl the ?s ?

Thanks for your help,
Zoltan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Find and replace "?" character

Enclose the ? in brackets:
Private Sub CommandButton2_Click()
Dim rng1 As Range
Dim mycell1 As Range
Set rng1 = Range("h98:i100")
For Each mycell1 In rng1

If Not mycell1.Find([?]) Is Nothing Then
mycell1.Replace What:=[], replacement:=""
End If
Next
End Sub

Et

--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"Zoltan" wrote:

Hello,

I have an easy question which I could solve so far.
I would like to find all ? character on a worksheet and delete it from each
cells.

My code is:

Private Sub CommandButton2_Click()
Dim rng1 As Range
Dim mycell1 As Range
Set rng1 = Range("h98:i100")
For Each mycell1 In rng1

If Not mycell1.Find("?") Is Nothing Then
mycell1.Replace What:="?", replacement:=""
End If
Next

End Sub


the result is, that it deletes each character, not just the ?s. My idea is,
that this is because ? is a special character to be used to look for
something which is not known in an expression.

How can I replace my ?s ? And onyl the ?s ?

Thanks for your help,
Zoltan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Find and replace "?" character

On Aug 23, 10:24 am, Michael
wrote:
Enclose the ? in brackets:
Private Sub CommandButton2_Click()
Dim rng1 As Range
Dim mycell1 As Range
Set rng1 = Range("h98:i100")
For Each mycell1 In rng1

If Not mycell1.Find([?]) Is Nothing Then
mycell1.Replace What:=[], replacement:=""
End If
Next
End Sub

Et

--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.



"Zoltan" wrote:
Hello,


I have an easy question which I could solve so far.
I would like to find all ? character on a worksheet and delete it from each
cells.


My code is:


Private Sub CommandButton2_Click()
Dim rng1 As Range
Dim mycell1 As Range
Set rng1 = Range("h98:i100")
For Each mycell1 In rng1


If Not mycell1.Find("?") Is Nothing Then
mycell1.Replace What:="?", replacement:=""
End If
Next


End Sub


the result is, that it deletes each character, not just the ?s. My idea is,
that this is because ? is a special character to be used to look for
something which is not known in an expression.


How can I replace my ?s ? And onyl the ?s ?


Thanks for your help,
Zoltan- Hide quoted text -


- Show quoted text -


To search for a character that is also a wildcard within a text
string, precede it with a tilde ~. That will specify the character,
not the wildcard, as the search criteria. Same thing works for find
and find/replace.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Find and replace "?" character

Put a tilde (~) character before the ?. You can also don't need to loop.

Range("h98:i100").Replace What:="~?", Replacement:=""


--
Hope that helps.

Vergel Adriano


"Zoltan" wrote:

Hello,

I have an easy question which I could solve so far.
I would like to find all ? character on a worksheet and delete it from each
cells.

My code is:

Private Sub CommandButton2_Click()
Dim rng1 As Range
Dim mycell1 As Range
Set rng1 = Range("h98:i100")
For Each mycell1 In rng1

If Not mycell1.Find("?") Is Nothing Then
mycell1.Replace What:="?", replacement:=""
End If
Next

End Sub


the result is, that it deletes each character, not just the ?s. My idea is,
that this is because ? is a special character to be used to look for
something which is not known in an expression.

How can I replace my ?s ? And onyl the ?s ?

Thanks for your help,
Zoltan

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Find and replace "?" character

Thanks for the helps. You solved my problem. Tilde works.

Zoltan

"Vergel Adriano" wrote:

Put a tilde (~) character before the ?. You can also don't need to loop.

Range("h98:i100").Replace What:="~?", Replacement:=""


--
Hope that helps.

Vergel Adriano


"Zoltan" wrote:

Hello,

I have an easy question which I could solve so far.
I would like to find all ? character on a worksheet and delete it from each
cells.

My code is:

Private Sub CommandButton2_Click()
Dim rng1 As Range
Dim mycell1 As Range
Set rng1 = Range("h98:i100")
For Each mycell1 In rng1

If Not mycell1.Find("?") Is Nothing Then
mycell1.Replace What:="?", replacement:=""
End If
Next

End Sub


the result is, that it deletes each character, not just the ?s. My idea is,
that this is because ? is a special character to be used to look for
something which is not known in an expression.

How can I replace my ?s ? And onyl the ?s ?

Thanks for your help,
Zoltan



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
I want to replace all "<br" with a new line character. Balaji Excel Discussion (Misc queries) 3 April 24th 23 09:02 PM
"Find" a wildcard as a place marker and "replace" with original va Eric Excel Discussion (Misc queries) 1 January 27th 09 06:00 PM
match true exact "dd" vs. find next 5th character=y nastech Excel Discussion (Misc queries) 4 February 28th 07 07:06 PM
How to replace "#N/A" w "0"when vlookup couldn't find the match? Holly Excel Discussion (Misc queries) 2 July 17th 06 11:48 PM
Replace dialog should put focus on "Find What" not "Replace With" Michael Williams Excel Discussion (Misc queries) 0 May 24th 06 12:45 PM


All times are GMT +1. The time now is 11:14 AM.

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"