Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
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
 
Old November 9th, 2005, 02:18 PM
Authorized User
 
Join Date: Nov 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old November 9th, 2005, 04:08 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

You can call a function from a procedure;
Something like this
Sub Remove()
    ActiveCell = DelStr(ActiveCell)
End Sub

-vemaju

 
Old November 9th, 2005, 06:46 PM
Authorized User
 
Join Date: Nov 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old November 10th, 2005, 11:34 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old November 10th, 2005, 02:15 PM
Authorized User
 
Join Date: Nov 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old November 10th, 2005, 03:41 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

One correction

Sub Remove()
Dim Cell as Range
For Each Cell in Selection
   Cell.Value = DelStr(Cell.Value)
Next
End Sub

-vemaju

 
Old November 14th, 2005, 03:10 PM
Authorized User
 
Join Date: Nov 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old November 15th, 2005, 02:33 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old November 15th, 2005, 07:07 PM
Authorized User
 
Join Date: Nov 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Vemaju,
How do we pass the function in Macro?
Please help
Thanks
D

D
 
Old November 15th, 2005, 07:24 PM
Authorized User
 
Join Date: Nov 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 10 Cannot Delete Character lucius BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 February 5th, 2008 12:45 AM
Cutting a character from a string arnabghosh Classic ASP Basics 2 August 18th, 2005 07:44 AM
Replacing a character from string itHighway Classic ASP Basics 5 March 14th, 2005 11:15 PM
Search for Character in String Kaynor09 Excel VBA 2 April 24th, 2004 11:13 AM
How do I get rid of the last character in a string Lucy Classic ASP Professional 3 September 30th, 2003 05:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.