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 = 2 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
就是我一按"输出",就把本个sheet的所有字节大于等于1的单元格内容写入到红框内的路径的文件的第一个"sheet"里?
但是如果这个叫1.xlsx的文档的单元格已经有内容的情况下,就写在下一行.
是写入,就是复制——选择性粘贴,值那个,不是单纯的复制粘贴. 展开
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 = 2 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
就是我一按"输出",就把本个sheet的所有字节大于等于1的单元格内容写入到红框内的路径的文件的第一个"sheet"里?
但是如果这个叫1.xlsx的文档的单元格已经有内容的情况下,就写在下一行.
是写入,就是复制——选择性粘贴,值那个,不是单纯的复制粘贴. 展开
2个回答
展开全部
你把set sh1 = thisworkbook.ActiveSheet 去掉,后面直接用Cells(i,j) 这样试试
追问
弄了,也不行呀/
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询