 |
| Excel VBA Discuss using VBA for Excel programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 9th, 2005, 02:18 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks your helpful about my problem, however do I run this function you've writen? Because I never used any function on Excel.
D
D
|
|

November 9th, 2005, 04:08 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
You can call a function from a procedure;
Something like this
Sub Remove()
ActiveCell = DelStr(ActiveCell)
End Sub
-vemaju
|
|

November 9th, 2005, 06:46 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Vemaju, I think you are very smart VB, and Excel expert. Do you work writing coding VB, and Excell a lot? Thank you very much about support. It helps me a lot of time to delete the lists I am working right now.
Also a question about the function you created, how do you use FOR Statement to search next cell?
Thanks
D
D
|
|

November 10th, 2005, 11:34 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
I work as an instructor.
Mainly I teach Excel and Access VBA.
You can use the following code to search next cell
Sub Remove()
Dim Cell as Range
For Each Cell in Selection
Cell = DelStr(Cell)
Next
End Sub
-vemaju
|
|

November 10th, 2005, 02:15 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Vemaju,
The way you pass the function RemoveStr something wrong because the function contain the String, while you pass in the function Range (Selection) that's why Sub() urgument dont recognize. Please take a look.
Thanks
D
D
|
|

November 10th, 2005, 03:41 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
One correction
Sub Remove()
Dim Cell as Range
For Each Cell in Selection
Cell.Value = DelStr(Cell.Value)
Next
End Sub
-vemaju
|
|

November 14th, 2005, 03:10 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Vemaju,
Thank you, your marco help me a lot of time to run my stuff excel, because anytime I run excel, I used formular to run those, but it helps, not like Marco you did for me that's helpful. I have another Formular to replace one Character:
Replace Tr if First Name is containing single character (i.e. H = Tr)
=IF(LEN(TRIM(B1))=1,"Tr",TRIM(B1))
Do you know how to write a marco replace single character? example above.
Thanks your help.
Danny
D
|
|

November 15th, 2005, 02:33 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Danny,
This is a function I use for replacing one single character
Function ReplaceChar(Word As String, OldChar As String, NewChar As String) As String
Dim i As Integer
For i = 1 To Len(Word)
If Mid(Word, i, 1) = OldChar Then
Mid(Word, i, 1) = NewChar
End If
Next
ReplaceChar = Word
End Function
-vemaju
|
|

November 15th, 2005, 07:07 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Vemaju,
How do we pass the function in Macro?
Please help
Thanks
D
D
|
|

November 15th, 2005, 07:24 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Oh I tested your function it works, the one you created just replace one Cell, what about if other cells they have string like: "Jimmy", "Bruce: it won't remove, it needs search any Range Cell(in that colum) has one Character will be replace to "Tr"..
Do you have any idea?
Sincerely your
Danny
D
|
|
 |