George Marup
New Member
![icon1.png](http://www.mrexcel.com/forum/images/icons/icon1.png)
Hi,
I have a VBA Code that select values from ranges (a2:v7) on the active sheet and paste onto another workbook (file path in Blue).All cells in this ranges (a2:v7) have formulas and hence the values in these ranges(a2:v7) are calculated as per the formula and displayed in the cell.
my problem is every time I click on the command button, it copies all the in the active sheet as per the range, even if sometimes there may be no values in the last two rows of my range(a2:v7), it also selects them and paste to my Result Databse workbook.And when I enter new data into my active sheet and try to run the macro again, instead of pasting to the next empty rows, the values a pasted two rows below.
Please assist, below is my code:
Code:
Private Sub CommandButton1_Click()
ActiveSheet.Range("A2:V7").Copy
Workbooks.Open Filename:="C:\Users\gmarup\Desktop\RESULTS DATABASE (CURRENT).xlsm"Worksheets("DATA").Select
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Cells(erow, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False
End Sub
Regards
George
Last edited by a moderator: