-1
Dim i, last As Integer
last = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To last
If Cells(i, 1) <> "" Then
Range("A1:C").Select
Selection.Copy
Sheets("Sheet2").Select
Application.Run "updatecc"
Range("A1:c").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet1").Select
Application.Run "updatecc"
End If
Next i
End Sub
帮助需要在这里,我想添加细胞依赖于sheet1单元格中的数据sheet2。 它仅复制第一个a1:c1值。 我需要从sheet1中复制并粘贴到sheet2中并生成单元格。如何在Excel表格中使用宏来生成单元格?
这不是一个解决方案,但请注意,Dim i,last As Integer'不声明为整数。它只声明“last”为整数,但“i”保持不变。要声明两者都是整数,你需要'Dim i As Integer,last As Integer'。这是VB之间的一个主要区别,Dim i,Last As Integer'声明为整数和VBA! –