excel下标越界 10
提示:Setws=Worksheets(name)下标越界,请教大侠如何解决呀!!?SubprocessOneSheet(nameAsString,ws2AsWorksh...
提示:Set ws = Worksheets(name)下标越界,请教大侠如何解决呀!!?
Sub processOneSheet(name As String, ws2 As Worksheet, ByRef nextRow As Integer)
Dim ws As Worksheet
Dim i As Integer, blankCount As Integer
Dim isFirstRow As Boolean
Set ws = Worksheets(name)
blankCount = 0
isFirstRow = True
For i = 3 To 1000
If (Len(ws.Cells(i, "N").Value) = 0 And Len(ws.Cells(i, "U").Value) = 0) Then
blankCount = blankCount + 1
If blankCount > 10 Then
GoTo PROCESS_ONE_SHEET_AFTER_FOR
End If
GoTo PROCESS_ONE_SHEET_BEFORE_NEXT_I
End If 展开
Sub processOneSheet(name As String, ws2 As Worksheet, ByRef nextRow As Integer)
Dim ws As Worksheet
Dim i As Integer, blankCount As Integer
Dim isFirstRow As Boolean
Set ws = Worksheets(name)
blankCount = 0
isFirstRow = True
For i = 3 To 1000
If (Len(ws.Cells(i, "N").Value) = 0 And Len(ws.Cells(i, "U").Value) = 0) Then
blankCount = blankCount + 1
If blankCount > 10 Then
GoTo PROCESS_ONE_SHEET_AFTER_FOR
End If
GoTo PROCESS_ONE_SHEET_BEFORE_NEXT_I
End If 展开
展开全部
已经提示的很明白了,数组那里For i = 3 To 1000 导致的,1000改小点
不然的话中间加入判断或Try
不然的话中间加入判断或Try
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Sub processOneSheet(name As String, ws2 As Worksheet, ByRef nextRow As Integer)
Dim ws As Worksheet
Dim i As Integer, blankCount As Integer
Dim isFirstRow As Boolean
dim j as integer
Set ws = Worksheets(name)
blankCount = 0
isFirstRow = True
j = Range("N65536").End(xlUp).Row
For i = 3 To j
If (Len(ws.Cells(i, "N").Value) = 0 And Len(ws.Cells(i, "U").Value) = 0) Then
blankCount = blankCount + 1
If blankCount > 10 Then
GoTo PROCESS_ONE_SHEET_AFTER_FOR
End If
GoTo PROCESS_ONE_SHEET_BEFORE_NEXT_I
End If
你再试试
Dim ws As Worksheet
Dim i As Integer, blankCount As Integer
Dim isFirstRow As Boolean
dim j as integer
Set ws = Worksheets(name)
blankCount = 0
isFirstRow = True
j = Range("N65536").End(xlUp).Row
For i = 3 To j
If (Len(ws.Cells(i, "N").Value) = 0 And Len(ws.Cells(i, "U").Value) = 0) Then
blankCount = blankCount + 1
If blankCount > 10 Then
GoTo PROCESS_ONE_SHEET_AFTER_FOR
End If
GoTo PROCESS_ONE_SHEET_BEFORE_NEXT_I
End If
你再试试
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询