Urgent - Run-Time Error "450"

J

Jeff

Hello,
I urgently need help with my VBA procedure. I'm getting the following erro
msg "Run-time '450'
Here's my VBA procedure
Sub trimit()
Dim a As Long
Dim myRng As Range
For a = 7 To 100
x = Mid(Application.Trim(Cells(a, 1).Range), 12, 20)

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
 
B

Bob Phillips

Sub trimit()
Dim a As Long
Dim myRng As Range
For a = 7 To 100
x = Mid(Application.Trim(Cells(a, 1).Value), 12, 20)

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


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
G

gromit12

Jeff,

I'm not entirely sure what you're trying to do, but here is some code
that is similar to yours but does not throw and error. HTH

Graham

Sub trimit()
Dim a As Long
Dim myRng As Range
For a = 7 To 100

Set myRng = Sheets('Sheet1").Range("A7:a100")
x = Mid(Application.Trim(myRng.Cells(a)), 12, 20)

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
 
Top