Excel VBA运行错误 求大神 Range("A3").Select 源码如下
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheets("户主").Select
For x = 2 To 440
Sheets("户主").Select
Sheets("模板").Range("C3").Value = Sheets("户主").Cells(x, "B").Value
W = 0
Z = Sheets("户主").Cells(x, "D").Value
For y = 2 To 1768
Sheets("人员").Select
If Z = Sheets("人员").Cells(y, "B").Value Then
V1 = Sheets("人员").Cells(y, "I").Value
W = W + 1
Sheets("模板").Cells(10 + W, "A").Value = V1
End If
Next y
b = Sheets("模板").Range("A7").Value
c = Sheets("模板").Range("E7").Value
zu = Sheets("户主").Cells(x, "D").Value
Sheets("模板").Select
' Sheets("调查模板-2").PrintOut
Sheets("模板").Copy
' ChDir ThisWorkbook.Path & "\采集表"
wn = zu & b & c & ".xlsm"
' Debug.Print "文件名:", wn
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\明白卡\" & wn, FileFormat:=xlExcel8
Windows(wn).Close True
Sheets("模板").Select
Range("A7:P19").ClearContents
Range("A3").Select
Next x
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
这个代码要有数据才能调试,如果只看代码看不出问题,你那边程序报错提示什么错误