Application.Trim with VBA
I'd suggest passing the range to a generic sub like:
Sub MySubst(Rg as Range)
Dim a As Long
x = Mid(Application.Trim(Rg.Value), 12, 20)
For a = 7 To 100
If a Mod 2 = 0 Then
If Cells(a, 1).Value 0 Then
Cells(a, 2).Value = x
Else
Cells(a, 2).Value = 0
End If
End If
Next a
End Sub
Called like this:
MySubst Range("A5")
--
Jim
"Jeff" wrote in message
...
| Hello,
|
| This is my VBA procedure.
| I wanted to know whether if was possible to subsitute "(Range("a5"))" with
| "a" in order to have a generic and moving range?
| Dim a As Long
| Dim myRng As Range
| x = Mid(Application.Trim(Range("a5")), 12, 20)
| For a = 7 To 100
| If a Mod 2 = 0 Then
| If Cells(a, 1).Value 0 Then
| Cells(a, 2).Value = x
| Else
| Cells(a, 2).Value = 0
| End If
| End If
| Next a
|
|
|
| --
| Regards,
| Jeff
|
|