I have a Excel sheet which has a button function.On clicking this button an Excel file can be selected.
The selected file has different set of worksheets. I would like to select a range of worksheet from this Excel file and paste in the current sheet which has the button function.
I tried with the code below, but I get error and the values are not pasted.
Can anyone help to do this..
Private Sub btnOpenExcel_Click()
' Variable declaration
Dim intCounter As Integer
Dim varFileToOpen As Variant
' Select files to open
varFileToOpen = Application.GetOpenFilename(Title:="Please select the file from which data should be copied. File #", FileFilter:="Excel Files *.xls (*.xls),")
If varFileToOpen = False Then
MsgBox "No file specified.", vbCritical, "ERROR!"
ActiveSheet.Range(DATE_COLUMN & (DATE_ROW)).Value = varFileToOpen
Dim strFirstFile As String
Dim strSecondFile As String
Dim wbk As Workbook
strFirstFile = "xxx"
Set wbk = Workbooks.Open(strFirstFile)
Set wbk = ActiveWorkbook
Thanks in advance