R
Rick S.
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
'=========
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