ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Urgent - Run-Time Error "450" (https://www.excelbanter.com/excel-discussion-misc-queries/84893-urgent-run-time-error-450-a.html)

Jeff

Urgent - Run-Time Error "450"
 
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
--
Regards,
Jeff


Bob Phillips

Urgent - Run-Time Error "450"
 
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)

"Jeff" wrote in message
...
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
--
Regards,
Jeff




[email protected]

Urgent - Run-Time Error "450"
 
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





Jeff wrote:
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
--
Regards,
Jeff




All times are GMT +1. The time now is 01:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com