复制不同的表格,并使它们一张 [英] copy different sheet and make them one sheet
问题描述
Sub hh()
'
'hh宏
'
'
范围(A1:A11)。选择
Selection.Copy
表格(Sheet1 )。选择
范围(B19)。选择
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:= 9
表格(Sheet2)。选择
范围(A2:A5)选择
Application.CutCopyMode = False
Selection.Copy
表格(Sheet1)。选择
范围(B30)。 b $ b ActiveSheet.Paste
End Sub
我手动重新编码了该代码
注意:这个答案是针对 Sub hh
的原始问题自此以来一直是edite d创建一个新问题
首先,您的原始代码可以重写为:
Sub hh()
表格(Sheet2)。范围(A1:A11)复制
表格(Sheet1 .Range(B19)。粘贴
表单(Sheet2)。范围(A2:A5)。复制
表格(Sheet1)。范围(B30)。 b
$ b End Sub
现在您可以根据最后一个行这是我相信你在问的。最后一行将如下所示:
(注释)
Sub hh()
'可变存储
中的最后一行Dim iLastRowSheet1 As Long
'将初始数据复制到内存
表单(Sheet2)。范围(A1:A11)。复制
'查找最后一行
带表格(Sheet1)
iLastRowSheet1 = .Range & .Rows.Count).End(xlUp).Row
结束
'使用最后一行粘贴+ 1
表格(Sheet1)。范围( B和(iLastRowSheet1 + 1))粘贴
'repeat
表格(Sheet2)。范围(A2:A5)。复制
Sheet1)
iLastRowSheet1 = .Range(B& .Rows.Count).End(xlUp).Row
结束
表单(Sheet1)。范围(B &(iLastRowSheet1 + 1))。粘贴
End Sub
I have two sheet 1 and 2. in sheet 1 I have a button that browse a file and paste it in into the second sheet so I need help to be able to browse for the second sheet and be able to paste it under the first one that is already exist in sheet 2. I would appreciate your help
Sub hh()
'
' hh Macro
'
'
Range("A1:A11").Select
Selection.Copy
Sheets("Sheet1").Select
Range("B19").Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=9
Sheets("Sheet2").Select
Range("A2:A5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("B30").Select
ActiveSheet.Paste
End Sub
i recoded this code manually
Note: This answer was for the original question with Sub hh
which has since been edited out to create a new question
First of all your original code can be rewritten as:
Sub hh()
Sheets("Sheet2").Range("A1:A11").Copy
Sheets("Sheet1").Range("B19").Paste
Sheets("Sheet2").Range("A2:A5").Copy
Sheets("Sheet1").Range("B30").Paste
End Sub
Now you can modify the paste location based on the 'last row' which is what I believe you are asking. The last row would be found like this:
(comments in line)
Sub hh()
'Varible to store the last row in
Dim iLastRowSheet1 As Long
'copy initial data to memory
Sheets("Sheet2").Range("A1:A11").Copy
'find current last row
With Sheets("Sheet1")
iLastRowSheet1 = .Range(B & .Rows.Count).End(xlUp).Row
End With
'paste using last row found + 1
Sheets("Sheet1").Range("B" & (iLastRowSheet1 + 1)).Paste
'repeat
Sheets("Sheet2").Range("A2:A5").Copy
With Sheets("Sheet1")
iLastRowSheet1 = .Range(B & .Rows.Count).End(xlUp).Row
End With
Sheets("Sheet1").Range("B" & (iLastRowSheet1 + 1)).Paste
End Sub
这篇关于复制不同的表格,并使它们一张的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!