应用程序定义在为单元格分配值时出错

时间:2014-10-16 06:39:19

标签: excel-vba vba excel

Sub APnumbers()
Dim i, Strnglen, Lastcell As Integer
Dim ws As Worksheet
Dim Currentcell As Range
Set ws = ActiveWorkbook.Sheets(2)
Lastcell = Range("AX1048556").End(xlUp).Row
For i = 4 To Lastcell
Set Currentcell = ActiveSheet.Range("BA" & i)
PACN= Currentcell.Value
Pnoposition = InStr(1, PACN, "1")
Pvalue = Mid(PACN, Pnoposition, 8)
With ws
       .Range("AY" & i).Value = Pvalue
   End With
End Sub

这里在第3行最后一行我得到一个应用程序定义或对象定义错误。你可以帮忙吗?

0 个答案:

没有答案