Hello! I am new to excel-vba programming. So basically Im trying to browse a file from the computer and COPY Data from that SELECTED File in Excel using vba, Im trying to select data from filled rows available in the selected excel workbook and paste it below existing data in the desired destination workbook here as "Masterfile.xlsm",
Can anyone PLEASE help me find errors here, suggestions to code in a better way are open.
Sub upload_data() Dim FileToOpen As Variant Dim OpenBook As Workbook Dim wscopy As Worksheet Dim wsdest As Worksheet Dim crow As Long Dim row As Long Application.ScreenUpdating = False FileToOpen = Application.GetOpenFilename(Title:="Browse for your file & Import Range", FileFilter:="Excel Files (*.xls*),*xls*") If FileToOpen <> False Then Set OpenBook = Application.Workbooks.Open(FileToOpen) End If Set wscopy = OpenBook.Worksheets(1) Set wsdest = Workbooks("Masterfile.xlsm").Worksheets(1) crow = wscopy.Cells(OpenBook.Rows.Count, "A").End(xlUp).row row = wsdest.Cells(wsdest.Rows.Count, "A").End(xlUp).Offset(1).row wscopy.Range("A2:J" & crow).copy wsdest.Range("A" & row).PasteSpecial xlPasteValuesAndNumberFormats Application.ScreenUpdating = True End Sub