Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
157 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...