I'm new to VBA but I'm trying.
I'm trying to when you press a button on the worksheet, to open another Excel file, get the rows from it and copy it to my current Excel file. I want this automated so you only have to press 1 button.
Private Sub CommandButton1_Click()
Dim src As Workbook
Set src = Workbooks.Open("C:\Users\gregg\Downloads\download.xls", True, True)
Dim iTotalRows As Integer
iTotalRows = src.Worksheets("download").Range("B1:B" & Cells(Rows.Count, "B").End(xlUp).Row).Rows.Count
Dim iCnt As Integer
For iCnt = 1 To iTotalRows
Worksheets("Elszamolas").Range("B" & iCnt).Formula = src.Worksheets("download").Range("B" & iCnt).Formula
Next iCnt
End Sub
This is what I have currently. I want to copy from file download sheet download to file napiElszamolas sheet Elszamolas. When I run the script I get "Subscript out of range" "Run-time error 9".