Excel vba出现这个窗口下标越界怎么处理?怎么改?
PrivateSubCommandButton1_Click()t=TimerApplication.ScreenUpdating=FalseDimi,j,r,wkAsW...
Private Sub CommandButton1_Click()
t = Timer
Application.ScreenUpdating = False
Dim i, j, r, wk As Workbook, sh As Worksheet, rr
s = TextBox1.Text
Set sh1 = ThisWorkbook.ActiveSheet
rr = ThisWorkbook.Worksheets("sheet1").[B65536].End(xlUp).Row
If s <> "" Then
Set wk = Workbooks.Open(s)
r = wk.Sheets(1).[B65536].End(xlUp).Row
Set sh = wk.Sheets(1)
For i = 1 To rr
For j = 1 To 60
If Len(sh1.Cells(i, j)) > 0 Then sh.Cells(i + r - 1, j) = sh1.Cells(i, j)
Next j
Next i
wk.Close True
End If
t1 = Timer - t
MsgBox ("处理完成,用时" & t1 & "秒")
Application.ScreenUpdating = True
End Sub 展开
t = Timer
Application.ScreenUpdating = False
Dim i, j, r, wk As Workbook, sh As Worksheet, rr
s = TextBox1.Text
Set sh1 = ThisWorkbook.ActiveSheet
rr = ThisWorkbook.Worksheets("sheet1").[B65536].End(xlUp).Row
If s <> "" Then
Set wk = Workbooks.Open(s)
r = wk.Sheets(1).[B65536].End(xlUp).Row
Set sh = wk.Sheets(1)
For i = 1 To rr
For j = 1 To 60
If Len(sh1.Cells(i, j)) > 0 Then sh.Cells(i + r - 1, j) = sh1.Cells(i, j)
Next j
Next i
wk.Close True
End If
t1 = Timer - t
MsgBox ("处理完成,用时" & t1 & "秒")
Application.ScreenUpdating = True
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询