How can i find the next empty row in a workbook where i want to paste some content i copied early in another workbook. This is what i get now:
Sub Retânguloarredondado1_Click()
Dim InputFile As Workbook
Dim OutputFile As Workbook
Dim Inputpath As String
Dim Outputpath As String '
Dim TP As Worksheet
Dim copyRange As Range
Dim pasteRange As Range
Dim cel As Range
Dim test As Range
Dim MyAr() As Variant
Dim n As Long
Dim LastRow As Long
' Set path for Input & Output
fileInputpath = "C:\Users\Nuno Bonaparte\Desktop\"
Outputpath = "C:\Users\Nuno Bonaparte\Desktop\"
'## Open both workbooks first:
Set InputFile = ActiveWorkbook
Set OutputFile = Workbooks.Open(Outputpath & "file2.xlsm")
Set TP = OutputFile.Worksheets("Folha1")
Set copyRange = InputFile.Sheets("file2").Range("A1,B3,C5,D7,E9")
Set pasteRange = OutputFile.Sheets("Folha1").Range("A1")
'~~> Get the count of cells in that range
n = copyRange.Cells.Count
'~~> Resize the array to hold the data
ReDim MyAr(1 To n)
n = 1
'~~> Store the values from that range into
'~~> the array
For Each cel In copyRange.Cells
MyAr(n) = cel.Value
n = n + 1
Next cel
'Now, paste to OutputFile worksheet:
OutputFile.Sheets("Folha1").Activate
pasteRange.Cells(1, 1).Resize(1, UBound(MyAr)).Value = _
MyAr
'Close InputFile & OutputFile:
'InputFile.Close
OutputFile.Save
OutputFile.Close
End Sub
The code works fine, but i would like to find the next empty row and paste the new content
Thank You.