LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default range.address, replace characters

I had "assumed" some arguments were optional.
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007



"Rick Rothstein (MVP - VB)" wrote:

Rick S is using the VBA Replace function which is a lot different than the
the REPLACE function from the spreadsheet side of things. VBA's Replace
function has 6 arguments, the last 3 of which are Optional.

Arg1: expression - Required. String expression containing substring to
replace.

Arg2: find - Required. Substring being searched for.

Arg3: replace - Required. Replacement substring.

Arg4: start - Optional. Position within expression where substring
search is to begin. If omitted, 1 is assumed.

Arg5: count - Optional. Number of substring substitutions to perform.
If omitted, the default value is €“1, which means make all possible
substitutions.

Arg6: compare - Optional. Numeric value indicating the kind of
comparison to use when evaluating substrings. See Settings section for
values.

Rick



"JLGWhiz" wrote in message
...
You are missing some arguments for the Replace Function:

expression.Replace(Arg1, Arg2, Arg3, Arg4)
expression Required. An expression that returns a WorksheetFunction
object.

Arg1 Required String. Text in which you want to replace some characters.

Arg2 Required Double. The position of the character in Arg1 that you
want
to replace with Arg4.

Arg3 Required Double. The number of characters in Arg1 that you want the
Replace method to replace with Arg4.

Arg4 Required String. Text that will replace characters in Arg1.



"Rick S." wrote:

I am having dificulties cyphering this.
'=========
Sub Test()
Dim rCells As Range, rLoopCells As Range
Dim OldAddress As Variant
Dim NewAdress As Variant

'Set variable to needed cells
If Selection.Cells.Count < 1 Then
MsgBox "You must select at least one cell"
Else
Set rCells = Selection
End If
For Each rLoopCells In rCells
OldAddress = rLoopCells.Address
NewAdress = Replace(OldAddress, "A", "D")
MsgBox NewAddress 'for testing
'ActiveSheet.Range(NewAdress).Value =
ActiveSheet.Range(OldAddress).Value
Next rLoopCells
End Sub
'=======

All I want to do is substitute the letter D for the letter A in the
address
of "OldAddress".
I am using msgbox to show results before I destroy my data but all I get
is
a blank msgbox.
What do I have wrong in the above code? (I know the problem lies within
the
"Replace" statement).

--
Regards

VBA.Noob.Confused
XP Pro
Office 2007



 
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
Address must be 18 characters long Derek M[_2_] Excel Worksheet Functions 3 June 1st 10 01:06 PM
How to create a range address with ADDRESS function? Steve McLeod Excel Worksheet Functions 1 December 18th 08 02:02 PM
Address can not be more than 30 characters NeSchw6G Excel Worksheet Functions 7 September 17th 08 10:20 PM
replace unicode characters shark102 Excel Programming 0 October 24th 07 08:03 AM
Replace non printable characters TonyL Excel Worksheet Functions 4 August 25th 07 01:03 PM


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